So I want to create a button, that changes its background image when the user presses down on it. My button is a division. Now I could simply use mousedown() and mouseup(), however there are many problems that can arise from this. For example a user could push the mouse down then move the mouse off the button. The user could also press alt-tab or something after mousing down. Either of these events would cause the button to stay pressed down even though the user has mouseup'ed. I could find a bunch of ways to overcome this stuff, however I was rather hoping Jquery may already have the functionality there. Here is my simple code:
(where #login is the button)
Cheers, J
Code:
$("#loginButton") .mousedown(function(){$(this).addClass("menuButtonDown")}) .mouseup(function(){$(this).removeClass("menuButtonDown")});
Cheers, J
Comment