|
|
在开发,客户提出这样的一个要求,把单选按钮,可以取消。考虑以后,只能用JS实现,代码如下
<html> <head> <title>单选按钮(radio)的取消与选中</title> </head> <body> <form> <input type="radio" name='radio' value="1" onclick='check(this)'>单选一 <input type="radio" name='radio' value="2" onclick='check(this)'>单选二 </form> <script language="javascript"> var tempradio= null; function check(checkedRadio) { if(tempradio== checkedRadio){ tempradio.checked=false; tempradio=null; } else{ tempradio= checkedRadio; } } </script> </body></html> |
|