阻止冒泡

<!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>
原文地址:https://www.cnblogs.com/jinsuo/p/7726281.html