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 the starting point of code execution in jquery? : jquery mobile

0 Answers  


How can we give face effect in jquery?

0 Answers  


What is a jquery library?

0 Answers  


What is the difference between jquery's ready and holdready?

0 Answers  


What is the use of delay() method in JQuery?

0 Answers  


Tell me how do you stop the currently-running animation? : jquery mobile

0 Answers  


Why is jquery better than javascript?

0 Answers  


What is the difference between javascript and jquery?

0 Answers  


Difference between $(this) and 'this' in jQuery?

1 Answers  


Which selector has better performance id or class and why?

0 Answers  


What is event.stoppropagation? : jquery mobile

0 Answers  


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

1 Answers  


Categories