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 event.PreventDefault in jQuery?
Give a brief idea about jquery mobile? : jQuery Mobile
How to multiple version of jQuery?
What is the advantage of using minimized version of jQuery?
Tell me an example usage of jquery mobile? : jquery mobile
Explain the difference between javascript and jquery? : jquery mobile
Can we have multiple document.ready() function on the same page?
What is the script build up by jQuery?
Do you have plans for a new jquery plug-in or something else we should look out for? Where to from here for the imgpreview plugin?
How to use transition effects? : jQuery Mobile
Why are not some scripts and styles loading? : jquery mobile
Can you use any other name in place of $ (dollar sign) in jQuery?