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


Please Help Members By Posting Answers For Below Questions

How is the deferred method in jquery important in relation to animate method?

593


How to use connect?

502


What is the use of jQuery load method?

508


What is event.stoppropagation? : jquery mobile

461


What is the difference between prop and attr?

429






What are the advantages of method chaining in jquery?

475


Which one is more efficient, document.getelementbyid( "idname") or $("#idname)?

425


How we can get the value of a radio button using jquery?

418


How do I check if an element is hidden in jQuery?

487


What is jQuery CDN?

502


What are the two types of CDNs?

598


What are the methods used to provide effects?

496


What are the advantages of minified version of jquery?

441


Can we call c# codebehind method using jquery?

404


What were the biggest challenges of getting the jQuery 1.7 release ?

475