代码改变世界

点击.box跟点击.box.box1

2016-12-02 14:58  改吧  阅读(482)  评论(3编辑  收藏  举报
<!DOCTYPE html>
<html>
<head>
    <meta charset='UTF-8'>
    <title>click</title>
    <script type="text/javascript" src='jquery-2.2.0.min.js'></script>
    <style type="text/css">
        div{
            width:200px;
            height:200px;
            background-color:red;
        }
    </style>
</head>
<body>
<div class='box'>
    hello
</div>
<div class='box box1'>
    hello
</div>
</body>
<script type="text/javascript">
    $('.box').click(function(){
        alert(1111);
    })
    $('.box.box1').click(function(){
        alert(3333)
    })
</script>
</html>

点击.box会出现1111

点击.box.box1的时候出现1111  3333弹出两次