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 |
List the advantage of using minimized version of jquery?
What is the use of val() method in jquery?
How to include jQuery in ASP.Net project?
How to check if number is numeric while using jQuery 1.7+?
What is eq()? : jquery mobile
Difference Between Prop and Attr in jQuery?
How to concatenate two strings using jquery?
What is the difference between the id selector and class selector in jquery?
Can we call c# codebehind method using jquery?
Why is not dom ready working for jquery mobile? : jquery mobile
How to search for descendant elements that match the specified selectors using ?
Explain why there are two different version of jquery library? : jquery mobile