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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:33:38+00:00 2026-05-27T18:33:38+00:00

I have a table with some values. The first row and first column contain

  • 0

I have a table with some values. The first row and first column contain values of such called vertical and horizontal sizes respectfully. What I need to do is to click on a table cell and get the horizontal and vertical values for that clicked table cell. What it basically means – get the value of first table cell in the row where the clicked table cell is located and get the first table cell value of the column where the clicked table cell is located. I’m getting the horizontal value with the following code:

var horizSize = $('th:first', $(this).parents('tr')).text();

But I’m not sure how to do that for the vertical line. How to get to the first table cell value of the column?

Thanks for helping.

  • 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-27T18:33:39+00:00Added an answer on May 27, 2026 at 6:33 pm

    I think the following should work:

    var verticSize = $('tr:first td').eq($(this).index()).text();
    

    JS Fiddle demo.

    Note that in the demo I’ve also amended your horizSize selector, to:

    horizSize = $(this).closest('tr').find('td:first').text();
    

    And subsequently refined to:

    horizSize = $(this).prevAll('td:last').text();
    

    The above assumes that you want the value of the cell from the :first tr element, whether that be in the thead or tbody. If you’ve marked up the heading cells as th then you’ll need to amend the td of the selector to th.


    Edited in response to Felix Kling’s comment:

    Instead of $('tr:first td'), $(this).closest('table').find('tr:first td') might be better (depending on the other markup).

    That’s something I should’ve thought of, myself, really. And, if there is more than one table in the document then this change would be essential, to demonstrate:

    var verticSize = $(this).closest('table').find('tr:first td').eq($(this).index()).text();
    

    JS Fiddle demo.

    References:

    • closest().
    • eq().
    • find().
    • :first selector.
    • index().
    • :last selector.
    • prevAll().
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some problem whith such mysql_query INSERT INTO table VALUES ('', CURDATE()-1) why
I have a data table which already has some values, plus it is getting
I'm having some trouble comparing values found in VARCHAR fields. I have a table
I have some table structure: <tr class=row-2><tr> <tr class=row-3>..<tr> <tr class=row-4>..<tr> <tr class=row-5>..<tr> <tr
I'm doing some manipulation and retrieval of values stored in a table. Each row
I have table with two SelectOneMenu in row. I need populate data in second
I have a transitional table that I temporarily fill with some values before querying
I have table that shows some records from database. each table has a column
I have a table which looks something like the following (first row is columns):
I have table with some fields that the value will be 1 0. This

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.