网络编程 
首页 > 网络编程 > 浏览文章

jquery获取radio值(单选组radio)

(编辑:jimmy 日期: 2025/12/25 浏览:3 次 )

单选组radio: $("input[@type=radio][@checked]").val();

单选组radio: $("input[@type=radio]").attr("checked",'2');//设置value=2的项目为当前选中项

获取一组radio被选中项的值

var item = $('input[@name=items][@checked]').val();

radio单选组的第二个元素为当前选中值

$('input[@name=items]').get(1).checked = true

单选组 radio: $("input[@type=radio]").attr("checked",'2');//设置value=2的项目为当前选中项

jquery老的版本

var_name = $("input[@name='radio_name']:checked").val();

jquery 1.3以后的版本

var_name = $("input[name='radio_name']:checked").val();

看个获取radio值的jquery实例

function getra(){

var_name = $("input[name='isspecialcnt']:checked").val();
//alert(var_name);
if(var_name=='1'){
$("#isspecialcntyes").show();
$("#isspecialcntno").hide();
}
if(var_name=='0'){
$("#isspecialcntyes").hide();
(www.jb51.net) $("#isspecialcntno").show();
}
}

<form name="form1" method="post" action="">
<p>
<label>
<input type="radio" name="radiogroup1" value="单选" id="radiogroup1_0">
单选</label>
<br>
<label>
<input type="radio" name="radiogroup1" value="单选" id="radiogroup1_1">
单选</label>
<br>
<label>
<input type="radio" name="radiogroup1" value="单选" id="radiogroup1_2">
单选</label>
<br>
<label>
<input type="radio" name="radiogroup1" value="单选" id="radiogroup1_3">
单选</label>
<br>
<label>
<input type="radio" name="radiogroup1" value="单选" id="radiogroup1_4">
单选</label>
<br>
<label>
<input type="radio" name="radiogroup1" value="单选" id="radiogroup1_5">
单选</label>
<br>
</p>
</form>
上一篇:让IE8浏览器支持function.bind()方法
下一篇:Javascript中的关键字和保留字整理
一句话新闻
高通与谷歌联手!首款骁龙PC优化Chrome浏览器发布
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网 网站地图 SiteMap