jQuery   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了jQuery插件命名空间大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
如何创建一个jQuery插件,以便我可以在我的插件中使用命名空间?
$("#id1").amtec.foo1();
$("#id1").amtec.foo2();

这些似乎都不行。

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

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

@L_944_3@

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

大佬总结

以上是大佬教程为你收集整理的jQuery插件命名空间全部内容,希望文章能够帮你解决jQuery插件命名空间所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。