沉沙
2018-06-14
来源 :
阅读 1694
评论 0
摘要:本篇jQuery教程讲解了获取radio值的方法,希望阅读本篇文章以后大家有所收获,帮助大家对jQuery的理解更加深入。
单选组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.bitsCN.com) $("#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>本文由职坐标整理并发布,了解更多内容,请关注职坐标WEB前端jQuery频道!
喜欢 | 0
不喜欢 | 0
您输入的评论内容中包含违禁敏感词
我知道了

请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式AI+学习就业服务平台 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号