开发者

jQuery - Own plugin - need small help

I created my own jQuery plugin in 1.4 and now I need a small amount of help.

$.etrade = function()
{

}

I need so I can build code like this

$.etrade = function()
{
    this开发者_如何学JAVA.var = 'setting';

    this.subfunction = function()
    {
    };
}

when I take function from my plugin I need to use it like this:

$.etrade.var = '5';
$.etrade.subfunction();

Somebody know what I mean? and how I can get this problem done? :)


It sounds like you want to assign a plain old object to $.etrade, not a function. Like this:

$.etrade = {
    variable: 'setting',
    otherVariable: 'something else',
    subfunction: function () { /* do stuff here */ },
    anotherSubFunction: function () { /* do other stuff here */ }
}

That said, I'm not sure how this qualifies as a jQuery plugin, since it looks like you're just tacking an ad-hoc property onto jQuery.

Aside: you can't use var as per your example, since it's a keyword in JavaScript.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜