您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

如何使用JavaScript设置radio选中的示例

2024/4/12 11:10:03发布28次查看
在页面数据绑定时,经常会遇到给radio设置选中,以下是我写的js方法,经测试可以使用。欢迎拍砖
<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选中的示例的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product