jQuery Plugin Namespace

后端 未结 5 1544
温柔的废话
温柔的废话 2020-12-23 18:18

How do I create a jQuery plugin so that I can use namespaces in my plugin ?

$(\"#id1\").amtec.foo1();
$(\"#id1\").amtec.foo2();

None of th

5条回答
  •  渐次进展
    2020-12-23 19:16

    (function($) {
        $.fn.amtec = function () {
            var jq = this;
            return {
                foo1: function(){
                    return jq.each(function(){});
                },
    
                foo2: function(){
                    return jq.each(function(){});
               }
           }
        };
    })(jQuery);
    

提交回复
热议问题