jQuery插件中的胶囊功能

时间:2019-06-07 10:52:10

标签: javascript jquery jquery-plugins

我想在另一个函数中调用checkWidth()函数。不幸的是,我不能真正做到这一点。在removeTag()函数中,checkWidth()函数未运行。

(function($) {
  $.fn.myplugin = function(elements) {
    this.checkWidth = function() {
      alert("test");
    };

    this.removeTag = function() {
      $(document).on("click", function() {
        this.checkWidth();
      });
    };

    this.initialize = function() {
      this.removeTag();
      return this;
    };

    return this.initialize();
  };
}(jQuery));

0 个答案:

没有答案
相关问题