jquery 阻止冒泡
2013-06-06 22:35
288 查看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Jquery 阻止冒泡</title>
<script type="text/javascript" src="../js/jquery-1.7.2.js"></script>
<style type="text/css">
.aa{
width:50px;
height:50px;
background-color:#ff0000;
}
.bb{
width:100px;
height:100px;
background-color:#000;
}
.cc{
width:200px;
height:200px;
background-color:#F0F;
}
</style>
</head>
<body>
<div class="bb">
<div class="aa"></div>
</div>
<div class="cc">
</div>
<script type="text/javascript">
(function(){
$(".bb").bind("click",function(){
if($(".cc").is(":visible")){
$(".cc").hide();
}else{
$(".cc").show();
}
})
$(".aa").bind("click",function(event){
event.stopPropagation();
})
}())
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Jquery 阻止冒泡</title>
<script type="text/javascript" src="../js/jquery-1.7.2.js"></script>
<style type="text/css">
.aa{
width:50px;
height:50px;
background-color:#ff0000;
}
.bb{
width:100px;
height:100px;
background-color:#000;
}
.cc{
width:200px;
height:200px;
background-color:#F0F;
}
</style>
</head>
<body>
<div class="bb">
<div class="aa"></div>
</div>
<div class="cc">
</div>
<script type="text/javascript">
(function(){
$(".bb").bind("click",function(){
if($(".cc").is(":visible")){
$(".cc").hide();
}else{
$(".cc").show();
}
})
$(".aa").bind("click",function(event){
event.stopPropagation();
})
}())
</script>
</body>
</html>
相关文章推荐
- jQuery之防止冒泡事件 默认事件阻止
- 浅谈jQuery 中的事件冒泡和阻止默认行为
- jquery 阻止冒泡事件实例 stopPropagation
- jquery阻止事件冒泡的两种方法
- jQuery阻止事件冒泡具体实现
- jquery 阻止默认事件(传播和冒泡)
- js /jquery停止事件冒泡和阻止浏览器默认事件
- jquery和javascript屏蔽右键菜单及阻止事件冒泡
- Jquery的冒泡事件的阻止与允许
- jQuery阻止冒泡和HTML默认操作
- jQuery中两种阻止事件冒泡的区别
- 关于jquery动态加载节点后阻止事件冒泡失效的问题
- jQuery阻止事件冒泡
- HTML事件冒泡和JQuery阻止事件冒泡的方式
- Jquery阻止事件冒泡
- JQuery阻止事件冒泡---阻止后续代码执行
- jquery 阻止事件冒泡
- jQuery阻止事件冒泡
- jQuery阻止事件冒泡具体实现
- jQuery冒泡事件阻止