我正在尋找一些教程,使自定義jQuery函數中的數組數據,但我找不到任何。你能告訴我如何在數組裏面爲jQuery函數創建一個數組嗎?我想打電話給我的功能是這樣的:如何在自定義jQuery函數的數組數據中創建數組?
$(this).myPlugin({
data_first: '1',
data_second: {
first_word : 'Hello', second_word : 'World'
}
});
我的功能腳本
(function($) {
$.fn.myPlugin = function(data) {
return this.each(function() {
alert(data['data_first']+' bla bla '+ data['data_second'][first_word]);
});
}
})(jQuery);
你對你的第二個代碼段的4行的丟失各地'first_word'報價 –