1

How to create jQuery namespace?

$.fn.zyl = {
  foo1 : function(){
   return this.each(function(){
       //...
   })}
}

I want to use $().zyl.foo1() but this.each is not a function. I'd like to use $().zyl.foo1() rather than $().zyl().foo1() or $().zyl('foo1').

zyl
  • 197
  • 1
  • 2
  • 12
  • Possible duplicate of [How to create jQuery Element Methods with NameSpace](http://stackoverflow.com/questions/17704130/how-to-create-jquery-element-methods-with-namespace) – chridam May 23 '16 at 07:46
  • Also possible duplicate http://stackoverflow.com/questions/527089/is-it-possible-to-create-a-namespace-in-jquery – Andrei May 23 '16 at 08:49
  • Their answers are `$().zyl().foo1()` or `$().zyl('foo1')`, I want to use `$().zyl.foo1()` and compatible with browsers. – zyl May 23 '16 at 09:52

0 Answers0