I've a custom plugin in jQuery,
jQuery.fn.dialog = function() {
return this.each(function() {
// Create dialog
});
};
现在我想添加一个函数,使其可以像这样被调用:-
$("#somediv").dialog.showMe();
我尝试做了这个:-
jQuery.fn.dialog.showMe = function() {
$(this).show();
// some code
};
但我认为这里的this
不是div,所以$(this).show()
不能起作用。
我该怎么做才能实现这个功能?有没有更好的方法来添加函数到jQuery插件中?
this.each
中实现这个? - Kaushikdialog.show();
不起作用。 - Kaushik