13-jquery 绑定事件、解绑

 

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="js/jquery.js"></script>
    <script>
        $(function(){

            /* 这种写法只能绑定一个事件
             $("#btn").click(function(){
                 ...
             })    */

             //用bind可以绑定多个事件
            $("#btn").bind('click mouseover',function(){
            alert("click和mouseover都能触发我")

            //unbind解绑,将绑定的事件解绑
            $(this).unbind('mouseover')
        
         })


        })
      
    </script>
</head>
<body>
    <input type="button" value="button" id="btn">
</body>
</html>

 

posted @ 2019-03-30 14:53  greenfan  阅读(88)  评论(0)    收藏  举报