<input type=
"radio"
name=
"radioname"
value=
""
/>全部
<input type=
"radio"
name=
"radioname"
value=
"Y"
/>是
<input type=
"radio"
name=
"radioname"
value=
"N"
/>否
js:
function
getRadioValue() {
var
radios = document.getElementsByName(
"radioname"
);
var
value;
for
(
var
i=0;i<radios .length;i++){
if
(radios[i].checked){
value = radios[i].value;
break
;
}
return
value;
}
jq:
var
value = $(
'input:radio[name="radioname"]:checked'
).val();
.attr(‘checked’): //看版本1.6+返回:”checked”或”undefined” ;1.5-返回:true或false
.prop(‘checked’): //16+:true/false
.is(‘:checked’): //所有版本:true/false//别忘记冒号哦
.prop(‘checked’): //16+:true/false
.is(‘:checked’): //所有版本:true/false//别忘记冒号哦