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
Post a Comment