Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditionally hide div based on if element is present on page

I am trying to figure out the best way to hide/show a left hand navigation menu on my volusion store.

Would it be possible via javascript/jquery to change the css display type of a div based on weather another element is present on the page?

The reason I ask is that the templating of this software is a bit convoluted. There is only a single skin file for the entire site. If I want the left hand navigation to load at all, it must be in the skin file. If it's in the skin file, it will load on every page but the homepage.

Because this is e-commerce software, I can easily add/remove content and elements from my informational pages, but the product and category pages load dynamically. I want to show the left hand menu on my info pages, but hide it on my product/category pages.

Which brings me back around to my original question. Since I am able to easily add an html element to my info pages, could I simply add a <br class="show-left-nav" /> to the page to trigger a javascript css change?

http://xlevj.jyetp.servertrust.com/contact-us_a/286.htm

Thanks!

like image 686
Alex Ritter Avatar asked Jan 18 '26 14:01

Alex Ritter


1 Answers

Yes !

if($('.someElement').length){  // returns true if element is present
  // show or hide another div
  $('.otherElement').hide();
}
like image 151
Mohammad Adil Avatar answered Jan 20 '26 02:01

Mohammad Adil