问显示,稳藏代码怎能么写,hookee() 还在吗
<script>
var oldobj = null;
var oldtd = null;
function show(n){
var obj = document.getElementById( "t " + n);
var td = document.getElementById( "td " + n);
if (oldobj!=null && oldobj != obj) oldobj.style.display= "none ";
if (oldtd!=null && oldtd != td) oldtd.style.backgroundImage= "url(none) ";
obj.style.display= "block ";
td.style.backgroundImage= "url(bg " + n + ".gif) ";
oldobj = obj;
oldtd = td;
}
window.onload=function(){oldobj = document.getElementById( "t1 ");}
</script>
<table width= "350 " border= "0 " cellpadding= "0 " cellspacing= "0 ">
<tr height= "21 ">
<td id= "td1 " style= "background-image:url(bg1.gif); " onmouseover= "show(1) "> 显示1 </td>
<td id= "td2 " style= "background-image:url(none); " onmouseover= "show(2) "> 显示2 </td>
<td id= "td3 " style= "background-image:url(none); " onmouseover= "show(3) "> "> 显示3 </td>
</tr>
<tr>
<td colspan= "3 ">
<table id= "t1 " style= "display:block; "> <tr> <td > 显示1内容 </td> </tr> </table>
<table id= "t2 " style= "display:none; "> <tr> <td > 显示2内容 </td> </tr> </table>
<table id= "t3 " style= "display:none; "> <tr> <td > 显示3内容 </td> </tr> </table>
</td>
</tr>
</table>
问题是这样的
1.刚开始是默认 "显示1 ",在表格内显示的是 "显示1内容 " 稳藏 "显示2内容 ", "显示3内容 "
2.点鼠标移到 "显示2 "在表格内显示的是 "显示1内容 " 稳藏 "显示1内容 ", "显示3内容 "
3.当鼠标在移到 "显示3 "时,在表格内显示的是 "显示3内容 " 稳藏 "显示1内容 ", "显示2内容 "
4.当鼠标在移到 "显示1 "时,在表格内显示的是 "显示1内容 " 稳藏 "显示2内容 ", "显示3内容 "
1.刚开始是默认 "显示1 ",在单元格背景色显示的是 "bg1.gif " 稳藏 "bg2.gif ", "bg3.gif "
2.点鼠标移到 "显示2 "在单元格背景色显示的是 "bg2.gif " 稳藏 "bg1.gif ", "bg3.gif "
2.点鼠标移到 "显示3 "在单元格背景色显示的是 "bg3.gif " 稳藏 "bg1.gif ", "bg2.gif "
2.点鼠标移到 "显示1 "在单元格背景色显示的是 "bg1.gif " 稳藏 "bg2.gif ", "bg3.gif "
以上代码是邮网友hookee() 写的,只是还有点小问题,就是刚开始时默认是对的,但当点 "显示2“或 "显示3 " ,
显示1的背景还在,所以会同时出现二个背景
------解决方案-------------------- <script>
var oldobj = null;
var oldtd = null;
function show(n){
var obj = document.getElementById( "t " + n);
var td = document.getElementById( "td " + n);
if (oldobj!=null && oldobj != obj) oldobj.style.display= "none ";
if (oldtd!=null &&