【发布时间】:2014-05-29 13:15:13
【问题描述】:
我正在使用 John Resig 的 Simple JavaScript Inheritance。
我知道我可以使用this 变量在方法之间共享值:
var Person = Class.extend({
init: function(isDancing){
this.dancing = isDancing;
}
});
我想创建一个指向 this 的指针,这样以后就不会被覆盖了:
$('#id').click(function() {
// this now points to selector
});
我如何创建可以在类范围内访问的 that = this 指针?
【问题讨论】:
-
不确定您的意思或该类将如何使用,但 jQuery 使用
bind在回调中设置this的正确值?
标签: javascript class oop this