jQuery綁定事件-多種實(shí)現(xiàn)方式總結(jié)

字號(hào):


    下面小編就為大家?guī)?lái)一篇jQuery綁定事件-多種實(shí)現(xiàn)方式總結(jié)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考
    jQuery綁定事件-多種實(shí)現(xiàn)方式總結(jié)
    <html>
    <head>
    <meta charset="utf-8" />
    <script src=https://pan.baidu.com/s/1o8GiuOq?qq-pf-to=pcqq.c2c></script>
    </head>
    <body>
    <input type="text"/>
    <input type="button" value="button1"/>
    <script>
    $(function(){
      var text = $(":text");
      var button = $(":button");
      //調(diào)試器記錄日志 console.log("message"); 如:火狐瀏覽器,打開FireBug(按F12)
      //觸發(fā)單個(gè)事件:兩種方式
      button.bind("mouseover",function(){
        console.log("移入");
      });
      button.bind({
        "mouseout": function(){
          console.log("移出");
        }
      });
      //多個(gè)事件:三個(gè)方式
      text.bind("dblclick blur",function(){
        console.log("雙擊或者失去焦點(diǎn)");
      });
      text.bind({
        "dblclick blur":function(){
          console.log("雙擊或者失去焦點(diǎn)");
        }
      });
      text.bind({
        "dblclick":function(){
          console.log("雙擊");
        },
        blur:function(){
          console.log("失去焦點(diǎn)");
        }
      });
      //取消事件
      text.unbind("dblclick"); //取消單個(gè)事件
      //text.unbind("dblclick blur"); //取消多個(gè)事件
      //text.unbind(); //取消全部事件
    });
    </script>
    </body>
    </html>
    以上這篇jQuery綁定事件-多種實(shí)現(xiàn)方式總結(jié)就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考