Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3980666
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:19:05+00:00 2026-05-20T05:19:05+00:00

When I click .getdata , I want to go from .getdata to name=top and

  • 0

When I click .getdata, I want to go from .getdata to name=top and read the value of whichever option is selected (in this case it’s 0), but I’m having a hard time getting to it. I keep getting undefined.

This is my html. The div class="main" repeats so I can’t simply select input[name=top]. It would have to be through traversing the tree to the closest input[name=top]. Can someone get this right? I’m starting to think it’s a browser error because I tried different options and all give me undefined.

<div class="main">
   <div class="branch">
       <div class="element">
          <label>top color:</label>
          <input type="radio" value="1" name="top">black
          <input type="radio" value="0" name="top" checked="checked">white
          <input type="radio" value="null" name="top">transparent
       </div>
   </div>
   <div class="controls">
      <a class="getdata">get data</a>
   </div>           
</div>

<div class="main">
....    
</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:19:06+00:00Added an answer on May 20, 2026 at 5:19 am
    $('a.getdata').click(function() {
        var val = $(this).closest('.main').find('input[name="top"]:checked').val();
    });
    
    • Place a click()(docs) event on the <a> element

    • On a click, use the closest()(docs) method to traverse up to the .main element

    • Then use the find()(docs) method along with the the attribute-equals-selector(docs) and the checked-selector(docs) to get the checked name="top" radio.

    • Finally use the val()(docs) method to get its value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When click a button,I want to popup a view form bottom,like this! Any help
READ FIRST I re-wrote this to make it more readable. If you want to
I want to get data from ADXL345 accelerometer,but seems that I incorrectly connect it.
This is my code i want to pass parameters to the flyout function but
Click here to see what I mean.. What could prevent these two from sitting
Click on this link , you will be redirected to a shopping site. On
I click on a link from one page that does a redirect to another
I click on items in my listbox and then hit a submit button, but
I am unable to read a pasted datagridviewrow object from the clipboard. All I
how can i get array value from php to javascript, and use the value

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.