jquery - Multiple event handlers on dynamic content with .on() -


we can attach multiple events element using .on()

$('.foo').on({     'click':function(e){         // stuff     },     'mouseenter':function(e){         // other stuff     },     'mouseleave':function(e){         // different stuff     } }); 

we can attach handler document , filter our elements have event on subsequently created elements

$(document).on('click', '.foo', function(e){     // stuff }); 

is possible combine these behaviours bind multiple events element , future elements?

yes;

$(document).on({     'click':function(e){         // stuff     },     'mouseenter':function(e){         // other stuff     },     'mouseleave':function(e){         // different stuff     } }, '.foo'); 

https://jsfiddle.net/ktybjprh/

this covered .on( events [, selector ] [, data ] ) signature, available of jquery 1.7


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -