What is the difference between event.stopPropagation and event.stopImmediatePropagation?
Answer Posted / 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 |
Post New Answer View All Answers
Can you use multiple document.ready() function on the same page?
Tell me is jquery a library for client scripting or server scripting? : jquery mobile
Differentiate the concepts of .js and .min.js?
what does $("div") will select? : jquery mobile
What is jquery.length? : jquery mobile
How to divide a page into parts using jquery mobile? : jquery mobile
How do you select an item using css class or id and get the value by use of jquery.
Explain the advantages of jquery?
What is the use of jquery.data()?
How to submit a form without submit button using jquery?
What are selectors in jquery? : jQuery Mobile
Explain the difference between .js and .min.js?
Can you please explain the difference between prop and attr? : jquery mobile
How to add or remove classes to an element in jquery?
What is event.PreventDefault in jQuery?