谁知道如何获取表格TD的背景颜色?(这个背景色是用CSS设置的)
代码如下,如何把TD的背景色读取出来?
<table width = "200" height = "200">
<tr>
<td style = "background:#CCCCCC" onClick = "alert(this.bgColor);">
aaaaa
</td>
</tr>
</tabel>
谢谢。
问题点数:100、回复次数:5Top
1 楼bencalie(Bencalie)回复于 2004-05-01 23:35:33 得分 100
<table width = "200" height = "200">
<tr>
<td style = "background:#CCCCCC" onClick = "alert(this.style.background);">
aaaaa
</td>
</tr>
</tabel>Top
2 楼vamzpqde(咕咕虫)回复于 2004-05-01 23:47:06 得分 0
谢谢bencalie(Bencalie),可我这个TD的背景色是用Javascript动态设置的,还是获取不了啊。
代码如下:
<html>
<head>
<style type="text/css">
.tdMouseOver {
background:#666666;
}
</style>
</head>
<body>
<table width = "200" height = "200">
<tr>
<td onMouseover = "this.className = 'tdMouseOver';" onClick = "alert(this.style.background);">
aaaaa
</td>
</tr>
</tabel>
</body>
麻烦帮一下,好吗?Top
3 楼vamzpqde(咕咕虫)回复于 2004-05-02 00:19:09 得分 0
谢谢,变通了一下,问题已解决。Top
4 楼bencalie(Bencalie)回复于 2004-05-02 00:20:08 得分 0
<html>
<head>
<style type="text/css">
.tdMouseOver {
background:#666666;
}
</style>
</head>
<body>
<table width = "200" height = "200">
<tr>
<td onMouseover = "this.className = 'tdMouseOver';" onClick = "alert(this.currentStyle.backgroundColor);">
aaaaa
</td>
</tr>
</tabel>
</body>
Top
5 楼vamzpqde(咕咕虫)回复于 2004-05-02 00:28:49 得分 0
好,那就用你的方法,晚安。Top




