Shoot event or press mouse button

Asked

Viewed 243 times

2

I’m applying an event change in id #estado, this has to happen when I click on the id #cidade.

I am working, but I noticed that only occurs when I click and release the button, how do I make it occur when I click?

OBS: if I click and keep holding the event does not occur, it will only occur when I release the mouse button.

$("#cidade").on("click", function () {
    $("#estado").change();
});

1 answer

1


In that case you can use the "mousedown" in time of "click". So when the mouse is pressed it runs the callback.

If you want tablet support join also the touchstart. The code could be like this:

$("#cidade").on("mousedown touchstart", function () {
    $("#estado").change();
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.