急,问个javascript的document对象问题?
来源:百度知道 编辑:UC知道 时间:2024/05/30 10:12:37
急,问个javascript的document对象问题?
<body bgcolor="#ffffff" onclick="alert(this.bgcolor==document.bgcolor)">
this.bgcolor==document.bgcolor 当前文档对象的背景色(等于=)文档对象的背景色,返回真
为什么我写成this==document就返回假了,怎么了,this当前对象是document,然后(this==document)没错啊
,怎么就返回false了,请指教!
<body bgcolor="#ffffff" onclick="alert(this.bgcolor==document.bgcolor)">
this.bgcolor==document.bgcolor 当前文档对象的背景色(等于=)文档对象的背景色,返回真
为什么我写成this==document就返回假了,怎么了,this当前对象是document,然后(this==document)没错啊
,怎么就返回false了,请指教!
我给楼主举个很简单的例子
拿我和楼主比
假设我们两个都是21岁(我们的属性)是相等的吧!
但是我们两个人(对象)相等吗?
肯定不相等...因为我们两个不是同一个人!
楼主明白了吧??
很简单的道理...呵呵....
祝楼主早日成功哈!
下面就能返回TRUE:
<body bgcolor="#ffffff" onclick="alert(this==document.body)">
知道了吧,this是不等于document的,只等于document.body