嗨我需要更改mouseMove属性onMouseMove但我无法访问myfunc对象,因为这是指el而不是父亲!!
function myfunc (el) {
this.el = el;
this.mousemove = false;
el.onmousemove = function(){
this.mousemove = true;
};
}
Run Code Online (Sandbox Code Playgroud)
只需存储一个引用this,无论你想要什么,都可以调用它.通常使用that或self:
function myfunc(el) {
var that;
that = this;
this.el = el;
this.mousemove = false;
el.mousemove = function () {
that.mousemove = true;
};
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
882 次 |
| 最近记录: |