Cur*_*ous 2 html javascript css
function cross() {
var dik = document.getElementsByName('r1c1')[0].parentNode;
dik.style.color = "red";
}Run Code Online (Sandbox Code Playgroud)
<table>
<tr>
<td><input type="radio" name="r1c1" value="TRUE"></td>
<td><input type="radio" name="r1c1" value="FALSE"></td>
</tr>
<tr>
<td><input type="radio" name="r1c2" value="TRUE"></td>
<td><input type="radio" name="r1c2" value="FALSE"></td>
</tr>
<input type="button" name="sbmt" value="CHECK" onclick="cross();">
</table>Run Code Online (Sandbox Code Playgroud)
当我单击按钮时,我想将td块的颜色更改为包含输入元素的红色<input type="radio" name="r1c1" value="TRUE">
您必须使用属性backgroundColor来更改的颜色td。color用于更改颜色text
<script type="text/javascript">
function cross(){
var dik = document.getElementsByName('r1c1')[0].parentNode;
dik.style.backgroundColor = "red";
}
</script>
<table>
<tr>
<td><input type="radio" name="r1c1" value="TRUE"></td>
<td><input type="radio" name="r1c1" value="FALSE"></td>
</tr>
<tr>
<td><input type="radio" name="r1c2" value="TRUE"></td>
<td><input type="radio" name="r1c2" value="FALSE"></td>
</tr>
<input type="button" name="sbmt" value="CHECK" onclick="cross();">
</table>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1668 次 |
| 最近记录: |