事件冒泡解决方案

冒泡解决方案

div  里面绑定div  2个DIV都绑定了 click事件,怎么点里面的div不会执行到外面DIV的事件,冒泡!这个案例 比较简单,仅供大家学习  案例下载地址



<!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>无标题文档</title>
</head>

<body>
<style>
.box{ border:1px #ddd solid; width:400px; height:400px; margin:0 auto;}
.search{ width:200px; height:200px; margin:100px; border:1px #000 solid}
</style>
<div class="box">
	<div class="search"></div>
</div>

<script type="text/javascript" src="js/jquery-2.0.3.min.js"></script>
<script>
	$(function(){
		$(".search").click(function(event){
			event.stopPropagation();
			alert("1")
		})	
		$(".box").click(function(event){
			
			alert("2")
		})
	})
</script>
</body>
</html>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

雪狼之夜

打个赏,让博主知道博文没白写

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值