开发者

unattach a jQuery function from a element

is this possible?

Like when you have a lightbox plugin: $('.foo').lig开发者_JAVA百科htbox()

Can you remove lightbox() from all .foo's, or only from specific a .foo ?


You might find this interesting Unbinding Plugins


You can do it two ways. One is to remove it from $ altogether - probably not what you want - by doing

$.lightbox = null;

If you want to do it to a set of elements, you would need to do this:

var elements = $('.foo');
elements.lightbox = null;

Note that this won't remove that function from subsequent calls to $, as that will generate a fresh jQuery object w/ all available plugins when you call it.


The selector applies to all instances.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜