How To Get Css Button To Stay Active After It Has Been Clicked?
Im trying to make a nav bar where once the user clicks on the image, the image stays active. In the following example the leaf would stay green after is is clicked. Here is a bit
Solution 1:
http://jsfiddle.net/bnaegele/XHBZf/2/
$('.myButtonLink').click(function() {
$(this).css('background-position', '0 0');
});
Solution 2:
You could apply a class to it on click.
$('.myButtonLink').click(function() {
$(this).toggleClass('active');
});
This code has an added effect of deselecting the leaf on a second click. Depending on your requirements, you might want it or not.
Post a Comment for "How To Get Css Button To Stay Active After It Has Been Clicked?"