开发者

unattach a jQuery function from a element

开发者 https://www.devze.com 2023-03-01 16:14 出处:网络
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 interestin

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

精彩评论

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