jQuery插件版本冲突的处理方法分析

作者:袖梨 2022-06-25

  你好

  (function($) {

    $.fn.myshowHtml =function() {

      alert("我是老版本:"+this.html());

    }

  })(window.jQuery);

  (function($) {

    varold = $.fn.myshowHtml;

    $.fn.myshowHtml =function() {

      alert("我是新版本:"+this.html());

    }

    $.fn.myshowHtml.noConflict =function() {

      $.fn.myshowHtml = old;

      returnthis;

    };

  })(window.jQuery);

  $(function() {

    $(".container").myshowHtml();

    $.fn.myshowHtml.noConflict();

    $(".container").myshowHtml();

  })

相关文章

精彩推荐