2010-09-16 17:13:38 +00:00
<!DOCTYPE html>
< html lang = 'en' > < head > < meta http-equiv = 'content-type' content = 'text/html; charset=UTF-8' / > < / head > < body >
2010-09-18 16:20:35 +00:00
< div data-role = "page" >
2010-09-21 14:58:54 +00:00
< div data-role = "header" >
2010-09-16 17:13:38 +00:00
< h1 > event.stopImmediatePropagation()< / h1 >
< / div >
2010-10-12 19:50:28 +00:00
< div data-role = "content" data-theme = "c" id = "event.stopImmediatePropagation1" >
2010-09-16 17:13:38 +00:00
< h2 class = "jq-clearfix roundTop section-title" >
< span class = "name" > event.stopImmediatePropagation()< / span > < span class = "returns" > < / span >
< / h2 >
< div class = " entry-details" >
< p class = "desc" > < strong > Description: < / strong > Keeps the rest of the handlers from being executed.
< / p >
< ul class = "signatures" > < li class = "signature" id = "event.stopImmediatePropagation" > < h4 class = "name" >
< span class = "versionAdded" > version added: < a href = "/category/version/1.3/" > 1.3< / a > < / span > event.stopImmediatePropagation()< / h4 > < / li > < / ul >
< div class = "longdesc" > < p > This method also stops the bubbling by implicitly calling < code > event.stopPropagation()< / code > . Use < code > event.isImmediatePropagationStopped()< / code > to know whether this method was ever called (on that event object).< / p > < / div >
< h3 > Example:< / h3 >
< div id = "entry-examples" class = "entry-examples" > < div id = "example-0" >
< h4 > < span class = "desc" > Prevents other event handlers from being called.< / span > < / h4 >
< pre > < code class = "example demo-code" > < !DOCTYPE html>
< html>
< head>
< style>
p { height: 30px; width: 150px; background-color: #ccf; }
div {height: 30px; width: 150px; background-color: #cfc; }
< /style>
< script src="http://code.jquery.com/jquery-latest.js"> < /script>
< /head>
< body>
< p> paragraph< /p>
< div> division< /div>
< script>
$("p").click(function(event){
event.stopImmediatePropagation();
});
$("p").click(function(event){
// This function won't be executed
$(this).css("background-color", "#f00");
});
$("div").click(function(event) {
// This function will be executed
$(this).css("background-color", "#f00");
});< /script>
< /body>
< /html> < / code > < / pre >
< h4 > Demo:< / h4 >
< div class = "demo code-demo" > < / div >
< / div > < / div >
< / div >
< / div >
< / div >
< / body > < / html >