最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

JQuery入門——移除綁定事件unbind方法概述及應(yīng)用

 更新時(shí)間:2013年02月05日 15:49:50   作者:  
在DOM對(duì)象的實(shí)踐操作中,存在用于綁定事件的bind方法,也會(huì)有相應(yīng)的移除綁定事件unbind方法,接下來將介紹unbind方法的使用,感興趣的朋友可以不要錯(cuò)過了啊,或許本文對(duì)你有所幫助

1、在DOM對(duì)象的實(shí)踐操作中,既然存在用于綁定事件的bind方法,也相應(yīng)存在用于移出綁定事件的方法,在JQuery中,可以通過unbind方法移除所有綁定的事件或某一個(gè)事件。

2、示例代碼

復(fù)制代碼 代碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>unbind方法移除綁定事件</title>
<script type="text/javascript" src="jquery-1.8.3.min.js"></script>
<script type="text/javascript">
$(function(){
function oClick(){ //自定義事件
$("#divTip").append("<div>這是按鈕二綁定的事件</div>");
};
$("input:eq(0)").bind("click",function(){
$("#divTip").append("<div>這是按鈕一綁定事件</div>");
});
$("input:eq(1)").bind("click",oClick);
$("input:eq(2)").bind("click",function(){
$("input").unbind("click",oClick);
$("#divTip").append("<div>刪除按鈕二事件</div>");
});
$("input:eq(3)").bind("click",function(){
$("input").unbind();
$("#divTip").append("<div>移出所有按鈕綁定的事件</div>");
});
})
</script>
</head>

<body>
<div>
<input id="button1" class="btn" value="按鈕一" type="button"/>
<input id="button2" type="button" value="按鈕二" class="btn"/>
<input id="button3" type="button" value="刪除按鈕二事件" class="btn"/>
<input id="button4" type="button" value="刪除所有事件" class="btn"/>
</div>
<div id="divTip"></div>
</body>
</html>

3、效果圖預(yù)覽
點(diǎn)擊按鈕一和按鈕二:


點(diǎn)擊刪除按鈕二事件在點(diǎn)擊按鈕二無反應(yīng)點(diǎn)擊按鈕一有反應(yīng):


點(diǎn)擊刪除所有事件后點(diǎn)擊所有按鈕無反應(yīng):


相關(guān)文章

最新評(píng)論

南漳县| 澄江县| 沈丘县| 原平市| 卓资县| 宿州市| 开江县| 乐东| 惠州市| 东城区| 陆丰市| 寻甸| 盖州市| 无棣县| 长沙市| 北海市| 华阴市| 外汇| 唐山市| 手游| 县级市| 临潭县| 苏州市| 阿荣旗| 剑阁县| 茂名市| 马山县| 卫辉市| 沁源县| 荔波县| 承德市| 普宁市| 云霄县| 都安| 连平县| 凤山市| 仲巴县| 鹤岗市| 娄底市| 清丰县| 揭西县|