时间:2021-07-01 10:21:17 帮助过:8人阅读
<html>
<head>
<script type="text/javascript" src="./jquery.min.js"></script></head><body><p>
<input id="rdo1" name="rdo1" type="radio" value="1" checked="checked"/>是
<input id="rdo1" name="rdo1" type="radio" value="0"/>否
<button id="btn1">是</button>
<button id="btn2">否</button><p><script type="text/javascript">
$(function(){
$("#btn1").click(function(){
$("input[name='rdo1']").eq(0).attr("checked","checked");
$("input[name='rdo1']").eq(1).removeAttr("checked");
$("input[name='rdo1']").eq(0).click();
});
$("#btn2").click(function(){
$("input[name='rdo1']").eq(0).removeAttr("checked");
$("input[name='rdo1']").eq(1).attr("checked","checked");
$("input[name='rdo1']").eq(1).click();
});
});</script></body></html>以上就是如何使用JavaScript设置radio选中的示例的详细内容,更多请关注Gxl网其它相关文章!