我需要一些關於我創建的jQuery插件的幫助。jQuery自定義函數 - this.each
$.fn.mymethod = {
init : function(options){
this.each(function() {
var settings = { };
if(options){ $.extend(settings, options); }
});
return this;
}
}
$("input[type=text]").mymethod.init();
它似乎沒有工作,我得到一個錯誤: 類型錯誤:this.each不就行了
功能我希望有人能指出我在正確的方向。
謝謝!
jQuery的枚舉對象,如數組$ .each。它也有一個.jach集合。你的'this'既不是數組也不是jQuery集合。您可以嘗試使用$ .each(this)獲取方法和其他屬性 – mplungjan