<style>
input{
i:expression(this.onclick=function() { document.getElementsByTagName('table')[0].style.color='red'; })
}
</style>
<body>
<table>
<tr><td><input type=radio name='r'>radio1</td></tr>
<tr><td><input type=radio name='r'>radio2</td></td></tr>
</table>
</body>
input{
i:expression(this.onclick=function() { document.getElementsByTagName('table')[0].style.color='red'; })
}
</style>
<body>
<table>
<tr><td><input type=radio name='r'>radio1</td></tr>
<tr><td><input type=radio name='r'>radio2</td></td></tr>
</table>
</body>
这段代码可以使文本变色的,但是如果我再加一个
<tr><td><input type=radio name='r2'>radio3</td><td>电风扇的</td></tr>
也会变色的
我想就两个RADIO,按下后两行变成不同颜色,不影响其他的内容
input{
i:expression(this.onclick=function() {setColor(this)})
}
</style>
<script>
function setColor(obj)
{
var t=obj.parentNode.parentNode;
if(t.rowIndex<2)
{
for(var i=0;i<2;i++)
t.parentNode.parentNode.rows[i].style.color='red';
}
}
</script>
<body>
<table>
<tr><td><input type=radio name='r'>radio1</td></tr>
<tr><td><input type=radio name='r'>radio2</td></td></tr>
<tr><td><input type=radio name='r'>radio3</td></td></tr>
</table>
</body>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>test</title>
<script language="javascript">
function c_color(ys)
{
td1.style.color=ys;
td2.style.color=ys;
}
</script>
</head>
<body>
<form method="POST" name="frm">
<table border="1" width="22%" id="table1">
<tr>
<td width="126" id="td1">111111111111111
</td>
<td rowspan="2">
<input type="radio" value="V1" name="R1" onclick="c_color('red')"><p>
<input type="radio" name="R1" value="V2" onclick="c_color('blue')">
</td>
</tr>
<tr>
<td width="126" id="td2" height="28">222222222222222</td>
</tr>
<tr>
<td width="126">33333333333333</td>
<td></td>
</tr></table>
</form>
</body>
</html>