Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
35
rated 0 times [  41] [ 6]  / answers: 1 / hits: 47059  / 14 Years ago, fri, august 13, 2010, 12:00:00

How do I loop through a radio buttons group without a form in JavaScript or jQuery?


More From » jquery

 Answers
35

What about something like this? (using jQuery):



$('input:radio').each(function() {
if($(this).is(':checked')) {
// You have a checked radio button here...
}
else {
// Or an unchecked one here...
}
});


You can also loop through all the checked radio buttons like this, if you prefer:



$('input:radio:checked').each(function() {
// Iterate through all checked radio buttons
});

[#95931] Wednesday, August 11, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
reecep

Total Points: 141
Total Questions: 95
Total Answers: 113

Location: Finland
Member since Mon, Nov 8, 2021
3 Years ago
reecep questions
Wed, Dec 8, 21, 00:00, 3 Years ago
Fri, Jul 30, 21, 00:00, 3 Years ago
Wed, Nov 18, 20, 00:00, 4 Years ago
Sat, Mar 14, 20, 00:00, 4 Years ago
Mon, Feb 3, 20, 00:00, 4 Years ago
;