jquery on()方法是官方推薦的繫結事件的乙個方法。
$(selector).on(event,childselector,data,function,map)由此擴充套件開來的幾個以前常見的方法有.
bind()以上三種方法在jquery1.8之後都不推薦使用,官方在1.9時已經取消使用live()方法了,所以建議都使用on()方法。$("p").bind("click",function());
$("p").on("click",function());
delegate()
$("#div1").on("click","p",function());
$("#div2").delegate("p","click",function());
live()
$("#div1").on("click",function());
$("#div2").live("click",function());
tip:如果你需要移除on()所繫結的方法,可以使用off()方法處理。
$(document).ready(function());tip:如果你的事件只需要一次的操作,可以使用one()這個方法$("button").click(function());
});
$(document).ready(function());trigger()觸發事件});});
$(selector).trigger(event,eventobj,param1,param2,...)
$(document).ready(function());多個事件繫結同乙個函式$("button").click(function());
});
$(document).ready(function());多個事件繫結不同函式});
$(document).ready(function(),繫結自定義事件mouseout:function(),
click:function()
});});
$(document).ready(function());傳遞資料到函式$("button").click(function());
});
function handlername(event)適用於未建立的元素$(document).ready(function(), handlername)
});
$(document).ready(function());$("button").click(function());
});
JQuery的extend方法詳解
jquery的extend擴充套件方法 jquery的擴充套件方法extend是我們在寫外掛程式的過程中常用的方法,該方法有一些過載原型,在此,我們一起去了解了解。一 jquery的擴充套件方法原型是 extend dest,src1,src2,src3.它的含義是將src1,src2,src3.合...
jQuery原型方法init的詳解
先來了解幾個jquery方法 li this jquery物件 aaa 的效果跟 的效果是一樣的。然後來看一下init方法,也就是新建jquery物件呼叫的方法 jquery.fn jquery.prototype 這時裡面的constructor指向會出問題,需要修正,person.prototy...
JQuery中 ajax 方法引數詳解
url 要求為string型別的引數,預設為當前頁位址 傳送請求的位址。type 要求為string型別的引數,請求方式 post或get 預設為get。注意其他http請求方法,例如put和 timeout 要求為number型別的引數,設定請求超時時間 毫秒 此設定將覆蓋 ajaxsetup 方...