Monday 15 July 2013

Jquery onClick toggleClass: only one div at a time -



Jquery onClick toggleClass: only one div at a time -

i have menu target using jquery function below. problem when home clicked , highlighted , want jump products there both active + both block-1 , block-2 show.

what trying when user clicked on , there decides switch b inactive , on. class stays constant meanwhile 1 of menu items active "content-removed".

what missing?

$(document).ready(function() { $(".home").click(function() { $(this).toggleclass("item-active"); $(".block-1").toggleclass("display"); $(".b1").toggleclass("visibility"); $(".content").toggleclass("content-removed"); }); $(".products").click(function() { $(this).toggleclass("item-active"); $(".block-2").toggleclass("display"); $(".b2").toggleclass("visibility"); $(".content").toggleclass("content-removed"); }); });

here html

<div class="block-1"> <div class="b1"><a href="#">home</a></div> <div class="b1"><a href="#">about</a></div> </div> <div class="block-2"> <div class="b2"><a href="#">overview</a></div> <div class="b2"><a href="#">health</a></div> </div>

jquery

No comments:

Post a Comment