ques-X3khDCqm

Search A2Z 24

Question : How to trigger the same function in jQuery multiple events ??

Is there any way to use multiple events(keyup, keypress,paste, blur, and change) for same function.

asked December 11, 2015

1 Answers

Dispalying 1 to 1 of 1 |

You can use .on() to bind a function to multiple events:

$("#element").on("keyup keypress blur change", function(e) {
    // e.type is the type of event fired
});

Or just pass the function as the parameter to normal event functions:

var myFunction = function() {
   ...
}
$("#element")
    .keyup(myFunction)
    .keypress(myFunction)
    .blur(myFunction)
    .change(myFunction)
See comments (0) | Comment
Answered More than a year ago
Dispalying 1 to 1 of 1 |

Write your Answer write code <pre class="brush: xml">---code---</pre>

Login as a member to access answering block !! click-here
loading...

Reveal Modal Goodness

This is a default modal in all its glory, but any of the styles here can easily be changed in the CSS.

This is just a simple modal with the default styles, but any type of content can live in here. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi quis sem vel enim eleifend tristique. Etiam tincidunt faucibus pharetra.

×