码迷,mamicode.com
首页 > 其他好文 > 详细

阻止冒泡

时间:2017-10-25 01:02:55      阅读:277      评论:0      收藏:0      [点我收藏+]

标签:color   htm   1.7   doctype   box   ret   code   pre   html   

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>阻止冒泡</title>
</head>
<body>
    <div class="box1">
        <div class="box2">
            <div class="box3">内容</div>
        </div>
    </div>
    
</body>
<script type="text/javascript" src="jquery-1.7.2.js"></script>
<script type="text/javascript">
    $(function(){
        $(‘.box3‘).click(function(){
            alert(‘box33333‘)
            stopBubble();
        });
        $(‘.box2‘).click(function(){
            alert(‘box2222‘)
        });
        $(‘.box1‘).click(function(){
            alert(‘box1111‘)
        });

            function stopBubble(e)
        {
            if (e && e.stopPropagation)
                e.stopPropagation()
            else
                window.event.cancelBubble=true
        }
        return false
    })



</script>
</html>

 

阻止冒泡

标签:color   htm   1.7   doctype   box   ret   code   pre   html   

原文地址:http://www.cnblogs.com/jinsuo/p/7726281.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!