What is the difference between event.stopPropagation and event.stopImmediatePropagation?
Answer / chaitanya
event.stopPropagation() allows other handlers on the same element to be executed, while event.stopImmediatePropagation() prevents every event from running. For example, see below jQuery code block.
Hide Copy Code
$("p").click(function(event){
event.stopImmediatePropagation();
});
$("p").click(function(event){
// This function won't be executed
$(this).css("background-color", "#f00");
});
If event.stopPropagation was used in previous example, then the next click event on p element which changes the css will fire, but in case event.stopImmediatePropagation(), the next p click event will not fire.
Is This Answer Correct ? | 0 Yes | 0 No |
What is the advantage of using minimized version of jQuery?
Why we use chaining in jquery?
What happen if you return false from a jQuery event handler?
What are the slow selectors in jQuery?
What is jQuery.noConflict?
Difference between parent() and parents() in jQuery?
What are the fastest selectors in jQuery?
Do we need to add jQuery file in both Master and Content page?
How can jquery be used in conjunction with another javascript library that also uses $ for naming?
How can events be prevented to work after an ajax request?
How to check variable is empty or not in jquery?
What the use of $ symbol in jquery.