Source: jQuery bind click *ANYTHING* but *ELEMENT*
1 2 3 4 5 6 7 |
$('#special').on('click', function(e) { e.stopPropagation(); }); $(document).on('click', function (e) { // Do whatever you want; the event that'd fire if the "special" element has been clicked on has been cancelled. }); |
Annuler les effets d’event.stopPropagation()
Source: How to undo event.stopPropagation in jQuery?
1 2 3 4 5 |
var stop = false; // do your logic here if(stop){ event.stopPropagation(); } |
Faire en sorte que le $(document).on(‘click’) n’agisse qu’une fois
Utiliser la méthode .off()
.
1 2 3 4 |
$(document).on('click', function(e) { console.log("This will be displayed only once."); $(this).off(e); }); |