我想創建一個jQuery插件,我想有以下幾種選擇:jQuery插件語法
$.plugin_name(variable)
$(selector).plugin_name(variable)
第一種情況的插件會不需要應用於元素(例如可以創建一個元素)第二種情況相同的插件將執行所選元素的任何操作
我的問題是:
if (selector is not given) {
create an element
} else {
(for example) insert variable in elements matching the selector
}
我其實是想知道,有一種方法來創作一個插件,可以做... 在沒有給出選擇器的情況下它會創建一個元素...所以理想情況下它可以被稱爲$ .pluginName()或$(selector).pluginName ()不是或者。 謝謝 – salmane 2010-01-24 02:10:42
這是不可能的,至少這是我的理解。 – 2010-01-24 02:17:01
可能的重複[我想了解jQuery插件語法](http://stackoverflow.com/questions/4484289/id-like-to-understand-the-jquery-plugin-syntax) – 2011-07-05 05:50:38