I have an HTML table having n rows and each rows contain one radiobutton in the Row.Using jQuery , How can i look thru these radio buttons to check which one is checked ?
$('#table tbody tr input[type=radio]').each(function(){
alert($(this).attr('checked'));
});
HTH.
To loop through all the radio checked radio buttons, you can also do this:
$('input:radio:checked').each(function() {
//this loops through all checked radio buttons
//you can use the radio button using $(this)
});
There are many ways to do that, e.g., using .each
and the .is
traversal method:
$("table tbody tr td input[name=something]:radio").each(function() {
if($(this).is(":checked")) {
$(this).closest("tr").css("border", "1px solid red");
} else {
// do something else
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With