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...

  1. the application multi-page.

in case can hard code class in page.

  1. 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

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -