1. 程式人生 > >JQuery 名稱空間

JQuery 名稱空間

This idea fails for plugins, however, since plugins expect this to refer to the jQuery object that started the chain. If I define $.fn.bar = function(){}, then when $(...).bar() is called, this refers to $(...), just as we want. But if I define $.fn.foo.bar = function(){}, then when $(...).foo.bar()
is called, this refers to $(...).foo, which is an object that knows nothing about jQuery. There's no way to make an object reference return something else.