为什么只有第一个的弹出才是正确的背景色??????????

lazydot 2006-11-11 09:38:45
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<style type="text/css">
<!--
.unnamed1 {
background-color: #0000FF;
}
-->
</style>
</head>

<body>
<table width="200" border="1">
<tr>
<td id="aaaa" style="background-color:#000000" onMouseOver="javascript:alert(document.getElementById('aaaa').style.backgroundColor)"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td id="bbbb" bgcolor="#666666" onMouseOver="javascript:alert(document.getElementById('bbbb').style.backgroundColor)"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td id="cccc" class="unnamed1" onMouseOver="javascript:alert(document.getElementById('cccc').style.backgroundColor)"> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
...全文
160 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
lazydot 2006-11-12
  • 打赏
  • 举报
回复
感谢感谢感谢啊!我对楼上的敬仰犹如。。。。
哈哈,真是十分感谢!前两天搞的我头都大了
chaoliu1 2006-11-12
  • 打赏
  • 举报
回复
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<style type="text/css">
<!--
.unnamed1 {
background-color: #0000FF;
}
-->
</style>
</head>

<body>
<table width="200" border="1">
<tr>
<td id="aaaa" style="background-color:#ff0000" onMouseOver="javascript:alert(document.getElementById('aaaa').style.backgroundColor)"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td id="bbbb" bgcolor="#666666" onMouseOver="javascript:alert(document.getElementById('bbbb').bgColor)"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td id="cccc" class="unnamed1" onMouseOver="javascript:alert(document.styleSheets[0].rules[0].style.backgroundColor)"> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>


哈哈,研究半小时,终于3个都出来了
njtucomputer 2006-11-11
  • 打赏
  • 举报
回复
style.backgroundColor 应该是取 style里的backgroundColor 属性值

其他虽然效果一样 但是取 style 取不到


我是这么理解的
lazydot 2006-11-11
  • 打赏
  • 举报
回复
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
lazydot 2006-11-11
  • 打赏
  • 举报
回复
为什么?为什么?为什么?

87,923

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧