如何将'this'范围转发到javascript中的函数调用

Vit*_*.us 2 javascript scope this

如何转发this范围引用调用事件监听器的元素?

为例:

<input type=button value="Foo" id=mybutton>
Run Code Online (Sandbox Code Playgroud)
addEvent('mybutton','touchstart', function(){
    if(window['touchmoved']==false)
    hover(); 
});


function hover(){
    this.value //undefined
}
Run Code Online (Sandbox Code Playgroud)

Rob*_*b W 7

使用JavaScript Function.callFunction.apply方法:

addEvent('mybutton','touchstart', function(){
    if(window['touchmoved']==false)
        hover.call(this); // `this` of the called hover points to this `this`
});
Run Code Online (Sandbox Code Playgroud)