Multiple events in JQuery selector

5

Does anyone know if / how can I assign multiple events to a JQuery element on a single line?

For example:

$('#elemento')
  .keyup(function(){...})
  .focusout(function(){..});
    
asked by anonymous 09.09.2015 / 21:13

1 answer

7

The documentation for .on() says:

Syntax:

  

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

and the event description says:

  

One or more space-separated event types

that is:

  

one or more event types separated by spaces.

An example would be:

$('#elemento').on('keyup focusout', function(){
    
09.09.2015 / 21:15