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
What are the features of jQuery, has been used in web applications?
How we can modify the css class in jquery?
How to use connect?
How do you get the text value of a selected option?
How to write browser specific code using jquery? : jquery mobile
Name some of the methods of jquery used to provide effects?
How can jquery library be added to pages? Write a basic jquery code?
How can you select all elements in a page using jquery?
How do you select all elements with the class of “selected” in jquery?
Explain the basic need to start with jquery? : jquery mobile
What is the difference between prop() and attr() in jquery?
What is the use of jquery.data()?
How to disable cut,copy and paste in TextBox using jQuery?
How do you install/use jquery in a project. What is the minimum setup needed to start using jquery.
Explain which program is useful for testing jquery?