3

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?

Ben Carp
  • 24,214
  • 9
  • 60
  • 72

2 Answers2

6

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(){});
0

You can use .mousedown()

$(document).off("mousedown","#ID").on("mousedown","#ID", function(){
...
});