社区
JavaScript
帖子详情
菜鸟问题!!!关于控制表格的单元格!
ldh_0421
2002-12-28 09:41:32
我想动态设置标个单元格的背景色,该怎么办?最好能提供源代码!
...全文
24
4
打赏
收藏
菜鸟问题!!!关于控制表格的单元格!
我想动态设置标个单元格的背景色,该怎么办?最好能提供源代码!
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
4 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
lbd8848
2002-12-28
打赏
举报
回复
<table border=0 width=100>
<tr><td id=a1>aaaaaaaaaaa</td></tr>
<tr><td id=b1>bbbbbbbbbbb</td></tr>
</table>
<script>
function setcolor()
{
a1.style.background="#ff0000";
b1.style.background="#0000ff";
}
</script>
<input type=button value="set color" onclick="setcolor()">
zhougong22
2002-12-28
打赏
举报
回复
什么样的动态,是鼠标移上变色,移走复原;还是根据不同的内容变。如果是前者,最简单的代码如下<td onmouseover="this.bgColor='red'" onmouseout="this.bgColor=''">
江南昆虫
2002-12-28
打赏
举报
回复
<table border=1 width=100>
<tr>
<td onmouseover="this.bgColor='red'" onmouseout="this.bgColor='green'">1233<br>456</td>
</tr>
</table>
liuzxit
2002-12-28
打赏
举报
回复
<style>
td.tdClass{background-color:#00ffff;}
</style>
<table border=1>
<tr><td id="td1">abc</td><td>lmn</td></tr>
<tr><td onclick="this.style.backgroundColor='#ff0000'">click here</td><td>xyz</td>
</tr></table>
<input type=button onclick="document.all('td1').style.backgroundColor='#ffff00'" value="User ID"><br>
<input type=button onclick="document.all.tags('table')[0].rows[0].cells[1].style.backgroundColor='#0000ff'" value="User Index"><br>
<input type=button onclick="document.all.tags('table')[0].rows[1].cells[1].className='tdClass'" value="User Class"><br>
JavaScript
87,996
社区成员
224,693
社区内容
发帖
与我相关
我的任务
JavaScript
Web 开发 JavaScript
复制链接
扫一扫
分享
社区描述
Web 开发 JavaScript
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章