1<table border="0" disabled="" id="rbl_bOwn" style="DISPLAY: none; POSITION: absolute">
2<tbody>
3<tr>
4<td><input id="rbl_bOwn_0" name="rbl_bOwn" type="radio" value="True"/><label for="rbl_bOwn_0">是</label></td>
5<td><input checked="" id="rbl_bOwn_1" name="rbl_bOwn" type="radio" value="False"/><label for="rbl_bOwn_1">否</label></td></tr>
6</tbody>
7</table>
我执行:
document.all["rbl_bOwn"].style.display="block";
就会出现找不到对像的错误,原因是table的id与input的name相同都为rbl_bOwn。因为上面的代码是asp.net里的RadioButtonList控件生成的客户端代码,我要动态控制该控件的css属性,请问有什么方法?
---------------------------------------------------------------
1<table border="0" disabled="" id="rbl_bOwn" style="DISPLAY: none; POSITION: absolute">
2<tbody>
3<tr>
4<td><input id="rbl_bOwn_0" name="rbl_bOwn" type="radio" value="True"/><label for="rbl_bOwn_0">是</label></td>
5<td><input checked="" id="rbl_bOwn_1" name="rbl_bOwn" type="radio" value="False"/><label for="rbl_bOwn_1">否</label></td></tr>
6</tbody>
7</table>
1<input id="button1" name="button1" onclick="test()" type="button" value="Button"/>
1<script language="javascript">
2<!--
3function test(){
4var o=document.getElementById("rbl_bOwn");
5o.disabled=false;
6o.style.display="";
7o.style.backgroundColor="#ffff00";
8}
9//-->
10</script>
---------------------------------------------------------------
id最好不要设置成相同,如果你坚持要这样做,也还是可以通过程序访问的
1<input id="gorush" value="text1"/>
1<input id="gorush" value="text2"/>
1<button onclick="document.all.gorush[0].style.color='red'">第一个</button>
1<button onclick="document.all.gorush[1].style.color='blue'">第二个</button>