javascript使用onclick事件改变选中行的颜色
摘要:html页面的table中一行一行的显示当然div也行可设置在鼠标放上去时改变其颜色部分代码如下复制代码代码如下:varcurrentAct...
html页面的table 中一行一行的显示当然 div也行 可设置在鼠标放上去时改变其颜色 部分代码如下
复制代码 代码如下:
<script type="text/javascript">
var currentActiveRow; //当前活动行
//改变选中行的颜色
function changeActiveRow(obj) {
if (currentActiveRow) {
currentActiveRow.style.backgroundColor = "";
}
currentActiveRow = obj;
currentActiveRow.style.backgroundColor = "#F2F2F2";
}
</script>
然后在td上设置onmousehover或者onclick事件即可 onmouseover="changeActiveRow(this)"
【javascript使用onclick事件改变选中行的颜色】相关文章:
上一篇:
使用js如何实现全选与全不选
下一篇:
js验证输入是否为手机号码或电话号码示例