I try to add click function but it doesn’t run…
$("#menu2 li").hover(function() { //On hover...
$(this).find("span").stop().animate({
marginTop: "-40" //Find the span tag and move it up 40 pixels
}, 250);
$("#menu2 li").click(function() { //On click...
$(this).find("span").stop().animate({
marginTop: "-40" //Find the span tag and move it up 40 pixels
}, 250); }
, function() { //On hover out...
$(this).find("span").stop().animate({
marginTop: "0" //Move the span back to its original state (0px)
}, 250);
});
});
here is the link:after click, i hope it still be white color
Update: After seeing your link and reading the explanation, I would do it this way:
Create a CSS class
selected:Add the class to the element on click and only perform the
mouseleaveaction if the element is not selected:I created a DEMO for you.
Old answer:
It should probably be: