Multiple events in Jquery selector

Asked

Viewed 534 times

5

someone knows if/how it is possible to assign multiple events to a Jquery element in a single row?

For example:

$('#elemento')
  .keyup(function(){...})
  .focusout(function(){..});

  • You can use $('#elemento').on('keyup focusout etc', function(){

1 answer

7


The documentation of .on() says:

Syntax:

.on( events[, selector] [, data], callback )

and the description of events says:

One or more space-separated Event types

that is to say:

one or more event types separated by spaces.

An example would be:

$('#elemento').on('keyup focusout', function(){
  • 1

    Thanks man, thank you!

  • 2

    @Leandrohermesness of nothing, I’m glad to help.

Browser other questions tagged

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