Reputation: 26568
The Jquery code
$(element).on("click", selector, handler)
, will trigger the handler function after the mouse button is released from the selected element. Is there a way to trigger the event when the mouse button is pressed?
Upvotes: 3
Views: 143
Reputation: 3329
You can use .mousedown()
$(document).off("mousedown","#ID").on("mousedown","#ID", function(){
...
});
Upvotes: 0
Reputation: 362
You can use the .mousedown()
Function to achieve what you want:
$( "#target" ).mousedown(function(){});
Or you can use the .on()
function and pass 'mousedown' as the action:
$( "#target" ).on('mousedown', function(){});
Upvotes: 6