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 |
How can we add change font size using jquery?
How can we apply css in last child of parent using jquery library?
What is event.PreventDefault?
How JavaScript and jQuery are different?
How to get the server response from an ajax request using jquery?
What is the latest version of jquery?
Whether we need to add jQuery file in both Master and Content page?
Explain the difference between onload() and document.ready() function used in jquery?
List the advantages of jquery?
What is the use of jquery .each() function?
How do I check if an element is hidden in jQuery?
Mention the advantages of cdn? : jQuery Mobile