Trigger event or mouse button

2

I'm applying a change event to the id #estado , this has to happen when I click the id #cidade .

This is working, but I noticed that it only occurs when I click and release the button, how do I make it happen when I click?

OBS: If I click and hold the event does not occur, it will only occur when I release the mouse button.

$("#cidade").on("click", function () {
    $("#estado").change();
});
    
asked by anonymous 05.05.2017 / 13:14

1 answer

1

In this case, you can use "mousedown" instead of "click" . So when the mouse is pressed it runs the callback.

If you want support for tablets, it also joins touchstart . The code could look like this:

$("#cidade").on("mousedown touchstart", function () {
    $("#estado").change();
});
    
05.05.2017 / 13:18