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 8799223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:16:09+00:00 2026-06-14T00:16:09+00:00

I have a 10 X 8 table. every row has 8 columns ie.., 8

  • 0

I have a 10 X 8 table.

every row has 8 columns ie.., 8 td elements. Each td in the row has a different class. Is it possible to get the info of 1st td element in the row, when i click on any of the other td’s in the row.

Basically i am creating a jquery onclick event on the column 2 to column 8 of each row. When i click on any of this column(td) it should get the info ie.., either id or class or name attribute of the column 1. I needs this one to send it on the server side code.

—
Thanks.

  • 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-06-14T00:16:10+00:00Added an answer on June 14, 2026 at 12:16 am

    Yes. From the clicked element, you navigate up to the row via closest, and then you can find the td with the relevant class with find or children (probably children in case you have nested tables):

    function clickHandler(e) {
        var cell = $(e.target).closest('tr').children('td.foo');
        // ...
    }
    

    Or if you always want the first td:

    var cell = $(e.target).closest('tr').children('td').first();
    

    That handler will work if it’s assigned to any td in the table, to the tr, or indeed to the tbody or table as a whole.

    Live Example | Source

    JavaScript:

    jQuery(function($) {
    
      // Put the handler on the tbody
      $("#target").click(clickHandler);
    
      function clickHandler(e) {
        var td = $(e.target).closest('tr').children('td').first();
        display("The text of the first <code>td</code> in that row is: " + td.text());
      }
    
      function display(msg) {
        $("<p>").html(String(msg)).appendTo(document.body);
      }
    
    });
    

    HTML:

    <table>
      <tbody id="target">
      <tr>
        <td class="one">This is one in row 0</td>
        <td class="two">This is two in row 0</td>
        <td class="three">This is three in row 0</td>
      </tr>
      <tr>
        <td class="one">This is one in row 1</td>
        <td class="two">This is two in row 1</td>
        <td class="three">This is three in row 1</td>
      </tr>
      <tr>
        <td class="one">This is one in row 2</td>
        <td class="two">This is two in row 2</td>
        <td class="three">This is three in row 2</td>
      </tr>
      </tbody>
    </table>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table where every row has a unique id. The last table
I have two tables that are very slightly different. Table A has 4 columns,
I have a data table. Each row of the table has a commandButton called
In my html page, I have one table, for every row there are two
I have a pivot table, well of course every row will be included in
i have 5 tables,in every table it has 4 rows. so i need to
I have a table with the following structure: (table_name, column_name) and for each row
Background I have a table which has six columns. The first three columns create
I have a table with the following columns id parent_id title description weight every
OK I have a table that has two columns, userID and courseID. It is

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.