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 do you check if an element exists or not in jQuery?
What is the difference between the knockout and jquery?
How to check or uncheck all checkboxes using jquery?
What is the difference between bind() and live() function in jquery?
How can you use array with jquery?
Name 3 available jquery plugins that bootstrap has in their query plugin library.
Describe the two types of cdns?
Explain .on()? : jquery mobile
Differentiate among .empty() vs .remove() vs .detach() in jquery.
What are the advantages of using cdn?
Explain cdn in jquery?
How to select class in jquery?