css 的问题?

来源:百度知道 编辑:UC知道 时间:2024/05/12 18:26:48
<style>
.thisgriditem{custom: expression(onclick=function(){if(this.style.backgroundColor=='skyblue'){this.style.backgroundColor="";}else{this.style.backgroundColor='skyblue';}})}}
</style>
我想将这个改成 当选择一个文本框时背景变色,再选择一个时上一个变会原色,当前的变色。该如何做?本人脚本不熟最好能说明白点。
先谢了。

完整代码如下:
=================================================================
<style>
.thisgriditem{
custom: expression(
onclick=function(){
var objt = document.getElementById("mytable");
for(var i=0;i<objt.rows.length;i++)
{
if(objt.rows[i].style.backgroundColor=='skyblue'){
objt.rows[i].style.backgroundColor="";
}

}
if(this.style.backgroundColor=='skyblue'){
this.style.backgroundColor="";
}
else{
this.style.backgroundColor='skyblue';
}
})
}
</style>

<table id="mytable" border="1" width="100" cellpadding="0" cellspacing="0" height="100">
<tr class="thisgriditem">
<td>df</td>
<td>fdsf</td>
</tr>
<tr class="thisgrid