jQuery获取单选框和多选框的值
单选框:
<label><input type="radio" name="radio" id="radio1" value="1" /> 25岁以下</label>
<label><input type="radio" name="radio" id="radio2" value="2" /> 25~35岁</label>
<label><input type="radio" name="radio" id="radio3" value="3" /> 35~50岁</label>
<label><input type="radio" name="radio" id="radio4" value="4" /> 50岁以上</label>
获值
var question1 = $('input:radio[name="radio"]:checked').val();
alter(question1);
复选框:
<label><input type="radio" name="radio2" id="radio21" value="1" /> 私募股权(PE)</label>
<label><input type="radio" name="radio2" id="radio22" value="2" /> 基金</label>
<label><input type="radio" name="radio2" id="radio23" value="3" /> 信托</label>
<label><input type="radio" name="radio2" id="radio24" value="4" /> 其他</label>
获值
var checkedObj = $('input:checkbox[name="checkbox"]:checked'); //获取当前checked的value值 如果选中多个则循环
checkedObj.each(function() { var isCheck = this.value; question3 += isCheck; });
alert("当前选中的"+question3);