jquery1.4提供了一个新的函数proxy。javascript的this属性不易控制,它通常表示的你正在操作的元素,但是有些情况下你希望它是之前的scope。
例如:
var app={ config:{ remark:'HELLO' }, clickHandler:function(){ alert(this.config.remark); } }; //这样是错误的 $('.test').bind('click',app.clickHandler); //这样就OK $('.test').bind('click',$.proxy(app,'clickHandler'));