代码描述:javascript改变 单选按钮radio状态。javascript动态改变单选按钮radio选中状态代码下载
有时候需要动态的改变单选按钮的选中状态,本章节通过实例代码介绍一下使用javascript如何实现此功能。 代码如下:
<!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name="author" content="http://www.51qianduan.com/" /> <title>51前端</title> <script type="text/javascript"> window.onload=function(){ var theradio=document.getElementById("theradio"); var bt=document.getElementById("bt"); bt.onclick=function(){ if(theradio.checked==true){ theradio.checked=false; }else{ theradio.checked=true; } } } </script> </head> <body> <input type="radio" id="theradio"/> <input type="button" id="bt" value="改变状态"/> </body> </html>
请绑定手机号,在继续操作
注意:只有绑定手机以后,才可使用网站全部功能