代码编辑器:
x
1
<script>
2
function displayResult(){
3
var x=document.getElementById("red").type;
4
alert(x);
5
}
6
</script>
7
<form>
8
你更喜欢哪种颜色?<br>
9
<input type="radio" name="colors" id="red">红色<br>
10
<input type="radio" name="colors" id="blue">蓝色<br>
11
<input type="radio" name="colors" id="green">绿色
12
</form>
13
<button type="button" onclick="displayResult()">显示 input 类型</button>
14