triggers - jquery: What happens after binding an event more than once? -
thanks jquery, .on method binds trigger element. have html like:
<div class='xyz'>click me</div> and script like:
$('.xyz').on('click', function(){ alert('why?'); }); $('.xyz').on('click', function(){ alert('why?'); }); clicking on click me div triggers alert 2 times. it's ok, but:
- what happens after binding second click trigger div?
- is browser behavior or done jquery variables?
here fiddle: http://jsfiddle.net/hpmhpm/fcrec/
what happens after binding second click trigger div?
jquery register's new click event handler on .xyz, no matter, how many event handler's attached element
is browser behavior or done jquery variables?
it's done jquery
you can have many event handler's want on same element, consider scenario -
this valid :
$('.xyz').on('click', function(){ // work }); $('.xyz').on('click', function(){ // other work });
Comments
Post a Comment