What is the difference between event.stopPropagation and event.stopImmediatePropagation?



What is the difference between event.stopPropagation and event.stopImmediatePropagation?..

Answer / 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

More jQuery Interview Questions

Explain url paremeter of jquery ajax method?

0 Answers  


Jquery can be used in what scenarios?

0 Answers  


What the use of $ symbol in jquery.

0 Answers  


What is meant by the term ‘theming’ in jquery mobile? : jQuery Mobile

0 Answers  


Tell me how to use migrate jquery plugin if possible? : jquery mobile

0 Answers  






What is the advantage of using the minified version of jquery rather than using the conventional one?

0 Answers  


What is chaining in jQuery?

1 Answers  


Define the use of each function in jquery?

0 Answers  


What does $("div.parent") will select?

1 Answers  


Tell me how to check if number is numeric while using jquery 1.7+? : jquery mobile

0 Answers  


Define type paremeter of jquery ajax method?

0 Answers  


How do I pull a native DOM element from a jQuery object?

0 Answers   MCN Solutions,


Categories