发表于: sitebuild | 作者: | 日期: 2008/4/03 11:04
标签: ,

this
用来返回“当前”对象。但在不同的场景,this 代表的对象并不相同。

如果在 JavaScript 的“主程序”中(不在任何 function 中,不在任何事件处理程序中)使用 this,它就代表 window 对象;
如果在 with 语句块中使用 this,它就代表 with 所指定的对象;
如果在事件处理程序中使用 this,它就代表发生事件的对象。

参考:http://www.quirksmode.org/js/this.html

: https://blog.darkmi.com/2008/04/03/123.html

本文相关评论 - 才一条评论
2011-10-20 21:15:14

最近正在研究这个,谢谢分享。

Sorry, the comment form is closed at this time.