1 现在有个列表table, 格式如下
list_a
list_b
list_c
...
list_n
我希望, 当我click其它的item时, 之前click的恢复到以前的颜色, 而click的改变颜色.
2 我现在有一些img类型的图片按扭, 我希望当我的鼠标mouseover时, 改变<td>的背景颜色, 而当我onmouseout时, 恢复以前颜色(注意:我用的背景图片), html代码如下:
<table cellSpacing=0 cellPadding=3 width="100%" border=0 class=form-noindent background="image/tool-bkgd.gif">
<tbody>
<tr>
<td width="1%" height="15" onmouseover="this.bgColor='#C3D5ED'"; onmouseout="this.background=image/delete.gif";><img style="cursor:hand" src="image/addtd.gif" onClick="addteam();"></td>
</tr>
</tbody>
</table>
谢谢
list_a
list_b
list_c
...
list_n
我希望, 当我click其它的item时, 之前click的恢复到以前的颜色, 而click的改变颜色.
2 我现在有一些img类型的图片按扭, 我希望当我的鼠标mouseover时, 改变<td>的背景颜色, 而当我onmouseout时, 恢复以前颜色(注意:我用的背景图片), html代码如下:
<table cellSpacing=0 cellPadding=3 width="100%" border=0 class=form-noindent background="image/tool-bkgd.gif">
<tbody>
<tr>
<td width="1%" height="15" onmouseover="this.bgColor='#C3D5ED'"; onmouseout="this.background=image/delete.gif";><img style="cursor:hand" src="image/addtd.gif" onClick="addteam();"></td>
</tr>
</tbody>
</table>
谢谢
解决方案 »
- 获取标签里面的属性值?
- canvas图形没有出来,这是怎么回事啊?
- 关于EXCEL导入问题
- 请问VB中怎样使用正则表达式打开txt文件,并匹配相关内容,把相应的匹配内容输出的一个excel文件中。
- 为什么在firefox下这段代码不行?其他浏览器下都行
- 自动列宽,用javascript设置其style.width
- 在线等,回帖时自动向ewebeditor编辑框引用主题的内容并且递交?
- 请教关于 NS 下的 modal 窗口控制
- 如何在关闭IE的时候打开另一个窗口,有谁能帮帮我!!
- 作一个iframe编辑器的问题?
- 求助:随滚动条而滚动层的效果问题,希望有人帮帮忙,感激不尽!
- 用户在线时间停留统计?
2,var arTd=oTable.getElementsByTagName("td")
for(var i=0;i<arTd.length;i++){
arTd[i].onmouseover=function(){
this.style.background="url(...)"
}
arTd[i].onmouseout=function(){
this.style.background="url(...)"
}
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<table width="200" border="1" id="tab">
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table><script type="text/javascript">
window.onload=function(){
var tab = document.getElementById("tab");
for(var i=0;i<tab.rows.length;i++)
{
tab.rows[i].onclick = function(){
if(tab.temp)
tab.temp.style.backgroundColor = "";
this.style.backgroundColor = "#cccccc";
tab.temp = this;
}
}
}
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<style type="text/css">
.default{background-image:url("http://www.google.cn/options/icons/picasa.gif")}/*默认图片*/
.over{background-image:url("http://www.google.cn/options/icons/patent.gif")}
</style>
<body>
<table width="200" border="1" id="tab">
<tr>
<td> </td>
<td> </td>
<td><img src="http://www.google.cn/options/icons/chrome.gif" name="test" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><img src="http://www.google.cn/options/icons/chrome.gif" name="test" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><img src="http://www.google.cn/options/icons/chrome.gif" name="test" /></td>
</tr>
</table><script type="text/javascript">
window.onload=function(){
var imgs = document.getElementsByName("test");
for(var i=0;i<imgs.length;i++)
{
imgs[i].parentNode.className = "default";
imgs[i].onmouseover = function(){
this.parentNode.className = "over";
}
imgs[i].onmouseout = function(){
this.parentNode.className = "default";
}
}
}
</script>
</body>
</html>