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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:31:45+00:00 2026-06-16T08:31:45+00:00

How can I get values of TDs inside an HTML table? i.e. | ID

  • 0

How can I get values of TDs inside an HTML table?

i.e.

| ID | cell 1 | cell 2 |
| 1  | aaaa   | a2a2a2 |
| 2  | bbbb   | b2b2b2 |
| 3  | cccc   | c2c2c2 |

So now if I click on the cell value: “bbbb” I want to get all the values of selected row:

$id='2'; $cell_1='bbbb'; $cell_2='b2b2b2';

NOTE: I’d like to use JavaScript and not jQuery.

  • 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-16T08:31:46+00:00Added an answer on June 16, 2026 at 8:31 am

    You can use event.target.innerText for javascript and $(event.target).text() for jQuery, jQuery is preferred solution as it handles cross browser competibilities.

    Using only javascript

    Live Demo

    Html

    <table id="tableID" onclick="myFun(event)" border="1">
      <tr>
         <td>row 1, cell 1</td>
         <td>row 1, cell 2</td>
      </tr>
      <tr>
         <td>row 2, cell 1</td>
         <td>row 2, cell 2</td>
      </tr>
    </table>​
    

    Javascript

    function myFun(e){ 
        alert(e.target.innerText); //current cell
        alert(e.target.parentNode.innerText); //Current row.
    }​
    

    Using jQuery

    Live Demo

    Html

    <table id="tableID" border="1">
       <tr>
           <td>row 1, cell 1</td>
           <td>row 1, cell 2</td>
       </tr>
       <tr>
           <td>row 2, cell 1</td>
           <td>row 2, cell 2</td>
        </tr>
    </table>​
    

    Javascript

    $('#tableID').click(function(e){
        alert($(e.target).text()); // using jQuery
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get the values inside tds. I can do it by getElementsByTagName
I´m trying to get the values of TDs inside a table using WatiN. The
Can any guru show me how to get values from HTML Form element -
can we get the values of the radio buttons , only those which has
How can I get the record values in the database to be sorted like
Can someone please let me know how to get values from several input fields?
I was reading How can I get query string values in JavaScript? on Stackoverflow
I have a very simple question, How can I get the POST values from
can i get validation on weight which can take decimal values and also integer.
How can I get a list of unique values in an array? Do I

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.