Пример:
Предотвратить выполнение остальных обработчиков событий за исключением существующего.
"jQuery"
$("p").click(function(event){ event.stopImmediatePropagation(); }); $("p").click(function(event){ // данная функция не будет ваполнена $(this).css("background-color", "#f00"); }); $("div").click(function(event) { // данныая функция будет выполнена $(this).css("background-color", "#f00"); });
"HTML"
paragraph
<div>division</div>
"CSS"
div { margin:3px; width:100px; height:100px;
background:green; float:left;color:white;}
"Живой пример jQuery"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="http://slyweb.ru/css/jqueryiframe.css"
rel="stylesheet" type="text/css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p").click(function(event){
event.stopImmediatePropagation();
});
$("p").click(function(event){
// данная функция не будет ваполнена
$(this).css("background-color", "#f00");
});
$("div").click(function(event) {
// данныая функция будет выполнена
$(this).css("background-color", "#f00");
});
});
</script>
</head>
<body class="iframe">
paragraph
<div>division</div>
</body>
</html>
<style>
div { margin:3px; width:100px; height:100px;
background:green; float:left;color:white;}
</style>