How to know which radio button is selected in jquery?
This question already has an answer here:
var selectedValue = $("input[name=form]:checked").val();
You should do it like this:
var radio = jQuery('input[name="form"]:checked');
You can then retrieve your radio value or other attributes:
var value = radio.val();
It's a good idea to see if any radio is checked before doing that:
if (radio != undefined)
{
//do what you need to
}
另外,你也可以试试这个 -
$(".modal-body input[type=radio]").each(function(){
if (this.checked)
{
console.log(this.value+" is checked");
}
});
链接地址: http://www.djcxy.com/p/24574.html
上一篇: 检测单选按钮是禁用还是启用