日期:2014-05-16  浏览次数:20367 次

求一段代码码(分不够再加)

四个TD一字排开,TD有背景图片,TD里有文字链接,要求:点击链接后,TD的背景图片替换成另外一张.现在问题是:点击一次以后,再次点击其它的TD时,这一张背景要恢复成以前的背景图片.

------解决方案--------------------
虽然没完成你的功能,但意思是一样的,改一改就行了
<script language= "JavaScript ">
<!--
var curOverRow=null;
var curClkRow=null;
function mouseover(objTr){
if(objTr==curClkRow) return false;
if(curOverRow)
curOverRow.style.backgroundColor= "white ";
curOverRow=objTr;
objTr.style.backgroundColor= "#00FF7F ";
}
function rowClick(objTr){
if(curClkRow){
curClkRow.style.backgroundColor= "white ";
curClkRow.style.color= "black ";
}
curClkRow=objTr;
objTr.style.backgroundColor= "#0000CD ";
objTr.style.color= "white ";
curOverRow=null
}

//-->
</script>
<style type= "css/text ">
td{text-align:center}
</style>
<body>
<script language= "JavaScript ">
<!--
document.write( " <table id= 'tbTest ' cellpadding=0 width=200 cellspacing=0 border=1 style= 'border-collapse:collapse ' borderColor= '#111111 '> ");
for(var i=0;i <4;i++){
document.write( " <tr height=30 onmouseover= 'mouseover(this) ' onclick= 'rowClick(this) '> <td width=50 align=center> "+(i+1)+ "-1 </td> <td align=center width=50> "+(i+1)+ "-2 </td> <td align=center width=50> "+(i+1)+ "-3 </td> <td align=center width=50> "+(i+1)+ "-4 </td> </tr> ");
}
document.write( " </table> ");
//-->
</script>
</body>