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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:50:10+00:00 2026-06-05T13:50:10+00:00

<table> <tr> <td>foo1</td> <td>bar1</td> <td><input type=button id=button1 onClick=get(this);></td> </tr> <tr> <td>foo2</td> <td>bar2</td> <td><input type=button

  • 0
<table>
  <tr>
    <td>foo1</td>
    <td>bar1</td>
    <td><input type="button" id="button1" onClick="get(this);"></td>
  </tr>
  <tr>
    <td>foo2</td>
    <td>bar2</td>
    <td><input type="button" id="button2" onClick="get(this);"></td>
  </tr>
</table>

Goal: To get buttons button1 and button2 to trigger the same function get() which should get the value of the first <td> in the same <tr> the button resides in. Which is, in this case: foo1 and foo2 respectively.

This is a rough outline of the function which should help understand what I’m trying to achieve-

function get(element){
  alert(element.tr.first_td.innerHTML);
}

I realize there was a jQuery solution to a similar problem. But I do not understand jQuery well enough to translate it back to JavaScript. If it is possible at all using JavaScript, please show me how.

  • 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-05T13:50:11+00:00Added an answer on June 5, 2026 at 1:50 pm

    Crawl up the parentNode twice to get to the tableRow element. From there, access the first td from the HTMLCollection of cells, and get the innerHTML value:

    function find( element ) {
        alert( element.parentNode.parentNode.cells[0].innerHTML );
    }​
    

    Fiddle: http://jsfiddle.net/jonathansampson/WuWnw/

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

Sidebar

Related Questions

I have a table that looks like this: FOO BAR BAZ ----+----+---- foo1 bar1
With a table like: idx type dat 0 a foo1 1 b foo2 2
I have a set of column names in a table - e.g. foo1, foo2,
How to insert into a table the result from a query like: ;with foo(foo1,foo2)
Table A has two columns: ID and name I want to input 3 ID
Table #1: qa_returns_items Table #2: qa_returns_residues I have a long time trying to get
I have a table say something like this: column_a column_b foo 1 bar 1
I have a somewhat complicated question related to MySQL. This is the table I
I have a table like this: column_a column_b foo 1 bar 1 bar 2
Code: $sql = 'UPDATE library/tablename ' . 'SET foo1 = \'THIS IS A TEST\',

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.