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
Tell me which program is useful for testing jquery?
What is the need for jquery? : jQuery Mobile
What programming language does jquery use?
What are two different version of jquery library? : jquery mobile
What is the use of jQuery load method?
What is the purpose of fadetoggle() method in jquery?
What is .detach()? : jquery mobile
What is the difference between $(window).load and $(document).ready function in jquery?
Can you please explain the difference between body onload() and document.ready() function? : jquery mobile
What is jQuery CDN?
explain width() vs css(‘width’) in jquery
What is the difference between jquery-x.x.x.js and jquery.x.x.x min.js?
How to submit a form without submit button using jquery?
Tell me how do you stop the currently-running animation? : jquery mobile
What is .remove()? : jquery mobile