0
我已經創建了一個插件,我有我的默認設置,但是當我更改調用腳本中的參數時,它們沒有被反映,默認值總是優先。我在這裏錯過了什麼?jquery插件無法識別調用參數
在我的.html文件
$('.inputBox').validate(function() {
rounded: true
});
調用腳本剝離下來插件。即使我在第一個片段中設置爲true,在我登錄到Firebug中的控制檯時,它總是假的。爲什麼是這樣?
(function($) {
$.fn.validate = function(options) {
var
defaults = {
rounded: false
},
settings = $.extend({}, defaults, options);
$(this).each(function(index) {
if(settings.rounded) {
$(this).addClass('roundedMsg');
}
});
return this;
};
})(jQuery);
你達人!謝謝! – Catfish 2010-02-11 01:01:37
他發佈的內容只是有效的JavaScript,因爲JavaScript支持標籤。他在一個函數中創建了一個名爲「rounded」的標籤。 – Prestaul 2010-02-11 01:02:26