Js 单选按钮 单击选中 双击取消
时间:2010-08-16 来源:JimmyCai
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>单选按钮,双击取消选中</title>
6 <script language="javascript" type="text/javascript">
7 window.onload = function() {
8 // setRadio("myDiv", "form1", "alreadySelected");
9 var radios = document.getElementsByTagName("input");
10
11 for (var i = 0; i < radios.length; i++) {
12 if (radios[i].type == "radio") {
13 radios[i].ondblclick = function() {
14 this.checked = false;
15 }
16 }
17
18
19 }
20 }
21 </script>
22 </head>
23
24 <body>
25 A:<input type="radio" name="rad" value="0" />
26 B:<input type="radio" name="rad" value="1" />
27 C:<input type="radio" name="rad" value="2" />
28 D:<input type="radio" name="rad" value="3" />
29
30 </body>
31 </html>
32
33
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>单选按钮,双击取消选中</title>
6 <script language="javascript" type="text/javascript">
7 window.onload = function() {
8 // setRadio("myDiv", "form1", "alreadySelected");
9 var radios = document.getElementsByTagName("input");
10
11 for (var i = 0; i < radios.length; i++) {
12 if (radios[i].type == "radio") {
13 radios[i].ondblclick = function() {
14 this.checked = false;
15 }
16 }
17
18
19 }
20 }
21 </script>
22 </head>
23
24 <body>
25 A:<input type="radio" name="rad" value="0" />
26 B:<input type="radio" name="rad" value="1" />
27 C:<input type="radio" name="rad" value="2" />
28 D:<input type="radio" name="rad" value="3" />
29
30 </body>
31 </html>
32
33
相关阅读 更多 +