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

  • SEARCH
  • Home
  • 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 903027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:48:36+00:00 2026-05-15T15:48:36+00:00

Im trying to get a form element value using closest. Here some example code.

  • 0

Im trying to get a form element value using closest. Here some example code.

<table>
  <tr>
    <td>Hour <input type="input" value="12" name="data[hour]" class="hour" /></td>
    <td>Minute <input type="input" value="12" name="data[minute]" class="minute" /></td>
    <td><a href="#" class="add-data">Add Row</a></td>
  </tr>
</table>

See I cant serialize the form because it is part of a large form so I need to grab each input closest to the add row link as yo will be able to add multiple rows.

I have tried

var hour = $(this).closest('.hour').val();    
var hour = $(this).closest('input', '.hour').val();
var hour = $(this).closest('input[name="data[hour]]").val();

Any ideas how I can get the form values ?

Thanks in advance

  • 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-15T15:48:36+00:00Added an answer on May 15, 2026 at 3:48 pm

    Assuming you have just one .hour element per tr, this will do it:

    var hour = $(this).closest('tr').find('.hour').val();
    

    closest will:

    Get the first ancestor element that
    matches the selector, beginning at the
    current element and progressing up
    through the DOM tree.

    So, you need to go up to the tr, and from there find the .hour descendant.

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

Sidebar

Related Questions

I am trying to get some form data from POST method. Here's the code
I'm trying to get the MIME type of an <input type=file /> element using
I'm trying to get all the input elements from a certain form from jQuery
I'm trying to get a table form a numpy array at the barplot bottom
I'm trying to get a filtering select work with a Dojo enabled form using
I am trying to get a HTML/PHP form to submit properly. Some details: base
I'm trying to get all form elements to array, then loop through them using
I am trying to pass a form element into an MVC3 view by using
I'm trying to fill out a form containing a textarea element. I'm using Python
Magento 1.6.1 I am trying to get form data on my observer. I tried

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.