1、获取Radio选中的值与文本
<input type="radio" name="advancedBespeak" value="1">是
<input type="radio" name="advancedBespeak" checked="checked" value="0">否
var advancedBespeakRadio=document.getElementsByName("advancedBespeak");
for(var i=0;i<advancedBespeakRadio.length;i++){
if(advancedBespeakRadio[i].checked==true) {
//选中的value
alert(advancedBespeakRadio[i].value);
//选中的text
alert(advancedBespeakRadio[i].nextSibling.nodeValue);
}
}
2、获取CheckBox选中的值与文本
<input type="checkbox" id="product" name="product" value="1">Apple
<input type="checkbox" id="product" name="product" value="2">HUAWEI
var products=document.getElementsByName("product");
for(var i=0;i<products.length;i++){
var product=products[i];
if(product.checked==true) {
//选中的value
alert(product.value);
//选中的text
alert(product.nextSibling.nodeValue);
}
}