how to retrieve value of radio button sets by class

I have a series of radio buttons with class="weight"
I thought I could get the current selected value with this:

$('.weight radio:checked').val()

...but does not seem to work. I also have them with a name="weight" so if its easier to do this by name, that would be an OK solution as well.

Thank you!
Brad BansnerWeb DeveloperAsked:
Who is Participating?
Gurvinder Pal SinghConnect With a Mentor Commented:
it should be


or just

Gurvinder Pal SinghCommented:
to fetch by name

Brad BansnerWeb DeveloperAuthor Commented:
Excellent, thanks.
just add << : >> and no space before radio : $(".weight:radio:checked").val()
test page :

$(".weight:radio").change(function() {
    //alert( $(this).val() );
    alert( $(".weight:radio:checked").val() );

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.