Hi!
I’m using the code below to hide elements (a group of text buttons) on certain pages. I have “show on all pages” turned on, and have added the code on the pages where I want it to hide. I found the code here on the Corvid forum. It seems temperamental and works sometimes, but most of the time, not at all. Sometimes it works in Preview mode and as I navigate, it decides to stop working entirely and won’t show the elements at all on any of the pages where it is not hidden. I’ve called Wix for help and they have directed me here. I’ve done a lot of troubleshooting but can not solve this problem and am hoping someone can help me. Thank you!
// Hides the element when the page loads
$w(“#group24”).hide();
Would help if you could post more than just that one line as it doesn’t show us anything else which could be causing your problem!
If you weren’t using the show on all pages option within the editor then you could have simply put it in your site tab and it would apply to your whole site.
As for your hide call, this needs to simply go on the page that you are wanting the group to be hidden on.
You should know that if you hide a global element on one page it may stay hidden on other pages (and vice versa). So you can’t rely on the default state, and you have to explicitly hide and show the elements on the relevant pages (you can do it on the site code panel and save time).
Interesting… I was thinking that could be the case. But that kind of defeats the purpose of the code, doesn’t it…? Or, would I only need to do this on the pages where I need to hide the elements?
@suzancreates It depends on how many pages you have.
Let’s say you have 100 pages and you want this elements to be hidden on 2 of them.
Then on the site code section (this code runs first) write: show() and in these specific 2 write hide().
But if let’s say you need it to be hidden on 50 pages, then you should create an array of the 50 pages paths and using wixLocation and the JS includes method make them hidden on the site code section.