How to get radio button selection with JQuery?
asp.net-mvc, jquery
Solution
I have no idea what the html will look like that your code makes. But, you can use this code to get each radio button's value. you can write a more specific selector yourself.
$("input:radio").each(function(){
if($(this).is(":checked")){
var val = this.value;
} else {
//not checked. do something else.
}
});
or get all the radios that are checked:
$("input:radio:checked").each(function() {
var value = this.value;
//do something with value of checked radiobox
});
Problem
I have MVC html control for radiobutton like: ``` <%= Html.RadioButton("Choice", false, new { onclick = "Accept()" })%><label for="Choice">Yes</label> <%= Html.RadioButton("Choice", false, new { onclick = "Deny()" })%><label for="Choice">No</label> ``` How to get radio button selection with JQuery?