我在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上面代表什么?就在我认为我弄清楚的时候......