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
Explain various methods to make ajax request in jquery? : jquery mobile
Explain the concepts of "$ function" in jquery with an example?
What to do to select element having a particular class (".selected")? : jquery mobile
Define the script build up by jquery?
What is the use of param() method?
Does jquery follow w3c recommendations?
How to validate email using jquery?
How to give face effect in jquery?
Difference between javascript and jquery? : jQuery Mobile
How we can check if an element is empty or not using jquery?
What is each() function in jQuery? How do you use it?
Can JQuery Run on MAC or Linux instead of Windows?
What is the purpose of jquery?
With jquery which operating system is more compatible?
What features of jquery, has been used in web applications?