jquery 一个对象绑定多个事件

<html>

    <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            #app {
                width: 100px;
                height: 100px;
                background-color: #eee;
            }
            #app p{
                height: 20px;
                background: #000000;
            }
        </style>
    </head>

    <body>
        <div id="app">
            <p></p>
        </div>
        
    </body>

</html>

 

 

1.   on()方法

$("#app").on("click mouseover", function() {
      console.log(1)
});

2.bind()方法

$("#app").bind("click mouseover", function() {
     console.log(1)
});

3.delegate()方法

$("#app").delegate("p", "click mouseover", function() {
    console.log(1)
});

 

posted @ 2019-03-26 17:41  氧化成风  阅读(1007)  评论(0编辑  收藏  举报