Why am I having issues getting a radio value in jQuery?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Samishii23
    New Member
    • Sep 2009
    • 246

    Why am I having issues getting a radio value in jQuery?

    Ok assume the following: I have most recent jQuery, and jQueryUI, the problem is occuring in code in a seperate js file within an object function.

    I have 8 radio buttons, each the same name.
    When I call the function which at the moment is just an alert...
    Code:
    function obj() {
      this.nav = function() {
        var val = $("input[name=radioButtons1]").attr("value");
        alert(val);
        }
      }
    This code produces an alert that is always the first radio buttons value despite any radio being checked, or a different radio then the one that has a different value. Same value everytime.

    I use this same method in another section of my website though that is in an event method. Also this method is not within form tags. The other one is.

    Whats wrong?
  • Samishii23
    New Member
    • Sep 2009
    • 246

    #2
    After messing around with it. I got this code to work.
    Code:
    $("input[name=radoButtons1]:checked").attr("value").
    Sorry for the wasted space.

    Comment

    Working...