相关疑难解决方法(0)

在jQuery中$ this vs $(this)

我在jQuery 上看到了关于$(this)vs的一些关于vs的讨论$this,它们对我有意义.(有关示例,请参见此处讨论.)

但是下面的代码片段,来自jQuery网站插件教程,展示了可链接性如何工作?

(function ($) {

    $.fn.lockDimensions = function (type) {

        return this.each(function () {

            var $this = $(this);

            if (!type || type == 'width') {
                $this.width($this.width());
            }

            if (!type || type == 'height') {
                $this.height($this.height());
            }

        });

    };
})(jQuery);
Run Code Online (Sandbox Code Playgroud)

$this上面代表什么?就在我认为我弄清楚的时候......

javascript jquery

74
推荐指数
12
解决办法
9万
查看次数

标签 统计

javascript ×1

jquery ×1