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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:28:20+00:00 2026-05-13T10:28:20+00:00

Ran into a bit of an issue with some jQuery code, but in essence,

  • 0

Ran into a bit of an issue with some jQuery code, but in essence, I have a table that may or may not have BR elements in the first column. When there are no BR elements the following code works fine and a value is returned. However, when there are BR elements, the code values to return any values for most of the columns. Any ideas what might be going on?

The following jQuery works correctly for the first row (‘Row-19’) and will show the value for each element; however, for the second row (‘Row-21’) only shows the values for the first and next-to-last column. In the production environment we are using this code to update or get the value in a given TD element on demand, so iterating through the columns isn’t the preferred option.

jQuery

alert($('#Row-' + id + ' :nth-child(' + ndx + ')').html());

XHTML Code

<tr id="Row-19">
    <td>Value</td>
    <td>Value</td>
    <td>Value</td>
    <td>Value</td>
    <td>1</td>
    <td>2</td>
    <td>
        <a href="#" title="Edit" onclick="edit('19');">[Edit]</a>&nbsp;
        <a href="#" title="Delete" onclick="delete('19');">[Delete]</a>
    </td>
</tr>
<tr id="Row-21">
    <td>
        Value<br />
        Value<br />
        Value<br />
        Value<br />
        Value<br />
    </td>
    <td>Value</td>
    <td>Value</td>
    <td>Value</td>
    <td>3</td>
    <td>4</td>
    <td>
        <a href="#" title="Edit" onclick="edit('21');">[Edit]</a>&nbsp;
        <a href="#" title="Delete" onclick="delete('21');">[Delete]</a>
    </td>
</tr>
  • 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-13T10:28:21+00:00Added an answer on May 13, 2026 at 10:28 am

    Works fine for me: http://jsbin.com/awame3

    $("a[title='Edit']").click(function(e){ 
      e.preventDefault();  
      $(this).parent().prevAll("td").each(function(){ 
        alert($(this).html()); 
      }); 
    }); 
    

    Updating a Specific Cell

    $("a[title='Edit']").click(function(e){
      e.preventDefault();
      var cell = $(this).closest("tr").find("td:eq(0)").html("new values");
      alert($(cell).html());
    });
    

    You could apply a class to whichever cell needs to be manipulated, and abandon addressing the indexes altogether:

    $(this).parent().siblings("td.editMe").html("new values");
    

    Getting Cells 2 – 5

    Using a filter, you could get cells 2 through 5:

    $(this).closest("tr").children("td:gt(0)").filter(":lt(5)");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bit complex to explain issue that I have ran into: I
I ran into an issue with some third party software that we use to
I'm writing a Fixedpoint class, but have ran into bit of a snag... The
Just ran into a bit of code that wasn't doing what I thought it
I've ran into a bit of an issue as I'd like two TextViews to
Trying to understand Ruby a bit better, I ran into this code surfing the
Ran into this error message while trying to select some records off a table.
I ran into a problem that suggests I may be implementing a design pattern
I have ran into a bit of a problem with my understanding of the
I ran into some singleton code today in our codebase and I wasn't sure

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.