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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:48:31+00:00 2026-06-10T10:48:31+00:00

I have this piece of code: <tr class=editField> <td>abc</td> <td>123</td> </td> </tr> <tr class=editField>

  • 0

I have this piece of code:

<tr class="editField">
  <td>abc</td>
  <td>123</td>
  </td>
</tr>
<tr class="editField">
  <td>dfg</td>
  <td>456</td>
  </td>
</tr>

And then I have this javascript to open a dialog with jQuery:

$( ".editField" ).click(function() {
        alert(...); // should get me 123
});

Suppose I click on first tr and I would get the content of second td (i.e 123), what should I write?

  • 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-10T10:48:33+00:00Added an answer on June 10, 2026 at 10:48 am

    I’d suggest, given your current mark-up:

    $( ".editField" ).click(function() {
            alert($(this).find('td:eq(1)').text());
    });
    

    But, while this works in the given example, it’d be much easier (and subsequently far more reliable) to add some defining attribute to the element from which you wish to recover the ‘value’, such as the class-name ‘value’, giving HTML like so:

    <tr class="editField">
      <td>abc</td>
      <td class="value">123</td>
    </tr>
    

    And the jQuery:

    $( ".editField" ).click(function() {
            alert($(this).find('td.value').text());
    });
    

    Or, of course, if the ‘value’ will always be the last td element of any given row (of the relevant class), then you could instead use:

    $( ".editField" ).click(function() {
            alert($(this).find('td:last').text());
    });
    

    Incidentally, please note that your HTML is malformed, you have a surplus </td> after the last cell in both rows of your sample code.

    References:

    • eq() selector.
    • find().
    • :last selector.
    • text().
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this piece of code: @Entity @Table(name = MOVERS) public class MOVers implements
I have this piece of code List<Class<? extends SubApplication>> appClasses = new ArrayList<Class<? extends
I have a piece of code like this: Class Program { static StreamReader sr
I have written this piece of code public class Test{ public static void main(String[]
I have this piece of code in my java class mystring = mysuperstring.split(/); I
At this time, I have this piece of code for my employee class. But
I have this piece of code: public class Authenticate : ActionFilterAttribute { public override
I have a template class that's a simple vector, but this piece of code
peace folks, I have this small piece of jquery based code, that grabs all
I have this piece of code: class Test { public static void main (String[]

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.