jquery - Javascript add class on click -
i trying add class link when clicked
here code
jquery(document).ready(function(){ jquery('#block-block-23 li a').click(function() { jquery('#block-block-23 li a').addclass("selected"); }); });
and problem class adding when clicking link when page loads automatically gets removed.i have tried toggleclass() function also
there can 2 scenarios...
- the application multi-page.
in case can hard code class in page.
- the application single-page , link decoration purpose.
in case can prevent default behavior of link.
jquery('#block-block-23 li a').click(function(event) { event.preventdefault(); jquery(this).addclass("selected"); });
Comments
Post a Comment