本文實例為大家分享了jQuery綁定事件多種實現方法,供大家參考,具體內容如下
<html><head><meta charset="utf-8" /><script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script><!--百度CDN--></head><body><input type="text"/><input type="button" value="button1"/><script>$(function(){  var text = $(":text");  var button = $(":button");  //調試器記錄日志 console.log("message"); 如:火狐瀏覽器,打開FireBug(按F12)    //觸發單個事件:兩種方式  button.bind("mouseover",function(){    console.log("移入");  });  button.bind({    "mouseout": function(){      console.log("移出");    }  });  //多個事件:三個方式  text.bind("dblclick blur",function(){    console.log("雙擊或者失去焦點");  });  text.bind({    "dblclick blur":function(){      console.log("雙擊或者失去焦點");    }  });  text.bind({    "dblclick":function(){      console.log("雙擊");    },    blur:function(){      console.log("失去焦點");    }  });    //取消事件  text.unbind("dblclick"); //取消單個事件  //text.unbind("dblclick blur"); //取消多個事件  //text.unbind(); //取消全部事件});</script></body></html>以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家繼續關注小編為大家分享的精彩文章。
新聞熱點
疑難解答