Can somebody tell me how to dynamically change the image of a button while clicking it?
My code:
$('.gamebox_minimap_plus').click(function() {
$(this).css("background-image","url('gfx/plus2.png')");
});
It works after a click, not while clicking, and does not come back to plus1.png after I stop clicking.
I think you want to use the mousedown and mouseup events.
jQuery .mousedown()
jQuery .mouseup()
In addition if you are using jQuery 1.7 or higher you should begin using/getting use to the on() and off() methods.