Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how to retrieve value of radio button sets by class

Posted on 2011-09-15
4
Medium Priority
?
262 Views
Last Modified: 2012-05-12
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!
0
Comment
Question by:bbdesign
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
Gurvinder Pal Singh earned 2000 total points
ID: 36544860
it should be

$('input[type='radio'].weight:checked').val()

or just

$('.weight:checked').val()
0
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 36544869
to fetch by name


$('input[name='weight']:checked').val()
0
 

Author Comment

by:bbdesign
ID: 36544972
Excellent, thanks.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36544973
just add << : >> and no space before radio : $(".weight:radio:checked").val()
test page : http://jsfiddle.net/dahVc/

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

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question