JS 获取Radio与CheckBox选中的值

获取Radio选中的值

	<input type="radio" name="advancedBespeak"  value="1"><input type="radio" name="advancedBespeak" checked="checked" value="0">

JS代码

var advancedBespeakRadio=document.getElementsByName("advancedBespeak");
for(var i=0;i<advancedBespeakRadio.length;i++){
	if(advancedBespeakRadio[i].checked==true) {
		alert(advancedBespeakRadio[i].value);
	}
}

获取CheckBox选中的值

	<input type="checkbox" id="product"  value="1">Apple					

JS代码

var product=document.getElementById("product");
if(product.checked==true) {
	alert(product.value);
}

猜你喜欢

转载自blog.csdn.net/tmaczt/article/details/82773974