I’ve created CSS sprite menu based on this tutorial:
http://buildinternet.com/2010/01/how-to-make-a-css-sprite-powered-menu/
Now I’d like to assign .selected class to the ‘a’ which was clicked as last one. I’ve added sipmle script:
<script>
$("a").click(function(){
$(this).addClass("selected");
});
</script>
but the class .selected appears only during loading the page. After loading whole page menu item returns to its normal state. Could you help me with this issue? TIA
Have a nice day:)
Clicking
awill take you to a different page, so this event is not gonna work for you. To addselectedclass to the current link you have to code like below:It will add class
selectedto link(s) if it’shrefmatches the current URL of the browser.