[英]jQuery - Own plugin - need small help
我在1.4中创建了自己的jQuery插件,现在我需要少量帮助。
$.etrade = function()
{
}
我需要,所以我可以构建这样的代码
$.etrade = function()
{
this.var = 'setting';
this.subfunction = function()
{
};
}
当我从插件中获取功能时,我需要像这样使用它:
$.etrade.var = '5';
$.etrade.subfunction();
有人知道我的意思吗? 以及如何解决这个问题? :)
听起来您想为$.etrade
分配一个普通的旧对象,而不是一个function
。 像这样:
$.etrade = {
variable: 'setting',
otherVariable: 'something else',
subfunction: function () { /* do stuff here */ },
anotherSubFunction: function () { /* do other stuff here */ }
}
就是说,我不确定这是否适合作为jQuery插件,因为看起来您只是在jQuery
上添加了一个临时属性。
另外:您不能按照示例使用var
,因为它是JavaScript中的关键字。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.