jquery更改运算符";这";处理事件时的行为? 请考虑以下课程。我开始使用JQuery function AutoHide(elemControl, elemContent) { this.elemControl = elemControl; this.elemContent = elemContent; this.delay = 500; this.duration = 500; this.direction = 'vertical'; this.effect = 'blind'; function softHide() { if ($(this.elemContent).is(':visible')) { $(this.elemContent).delay(this.delay); $(this.elemContent).hide(this.effect, {direction: this.direction}, this.duration); } return this; }; function softShow() { if ($(this.elemContent).is(':hidden')) $(this.elemContent).show(this.effect, {direction: this.direction}, this.duration); return this; }; function setClickControl() { alert(this.elemControl); $(this.elemControl).click(softToggleVisibility); }; this.softHide = softHide; this.softShow = softShow; this.setClickControl = setClickControl; };

jquery更改运算符";这";处理事件时的行为? 请考虑以下课程。我开始使用JQuery function AutoHide(elemControl, elemContent) { this.elemControl = elemControl; this.elemContent = elemContent; this.delay = 500; this.duration = 500; this.direction = 'vertical'; this.effect = 'blind'; function softHide() { if ($(this.elemContent).is(':visible')) { $(this.elemContent).delay(this.delay); $(this.elemContent).hide(this.effect, {direction: this.direction}, this.duration); } return this; }; function softShow() { if ($(this.elemContent).is(':hidden')) $(this.elemContent).show(this.effect, {direction: this.direction}, this.duration); return this; }; function setClickControl() { alert(this.elemControl); $(this.elemControl).click(softToggleVisibility); }; this.softHide = softHide; this.softShow = softShow; this.setClickControl = setClickControl; };,jquery,object,Jquery,Object,我有一个对象AutoHide的全局实例,softShow()和softHide()方法的工作方式就像一个符咒(通过Google Chrome的控制台)。但是,当我尝试运行setClickControl()方法时,我意识到操作符“this”指的是HtmleElement,而不是类本身。这正常吗?我习惯于认为操作符“这个”是对对象的一个引用,< p>你是正确的。在第一次使用jQuery时,隐藏普通的“this”对象会导致很多混乱。如果确实需要按照习惯的方式执行“this”,请使用jQuery pro

我有一个对象AutoHide的全局实例,softShow()和softHide()方法的工作方式就像一个符咒(通过Google Chrome的控制台)。但是,当我尝试运行setClickControl()方法时,我意识到操作符“this”指的是HtmleElement,而不是类本身。这正常吗?我习惯于认为操作符“这个”是对对象的一个引用,

< p>你是正确的。在第一次使用jQuery时,隐藏普通的“this”对象会导致很多混乱。如果确实需要按照习惯的方式执行“this”,请使用jQuery proxy()API函数:


我概述了三种操作此中
this
指针的方法-通过
jQuery.proxy
在闭包中捕获
this
,以及ES3中函数的新
bind
方法。所有这些技术的基本方法都是相同的——在闭包中捕获
这个
,然后引用它。jQuery的
.proxy
和函数原型的
.bind
都是简单方便的包装器。您可以添加一个如何调用成员函数的示例吗?