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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:47:31+00:00 2026-05-25T01:47:31+00:00

I have a table as shown below. Upon click on the edit I want

  • 0

I have a table as shown below. Upon click on the edit I want to have the value of the first TD, i.e date, how can I do that, even with the second row?

    <table id="foo" border="1px">
<tr> 
                    <td rowspan='3' id="date"> 
                     Monday5                   </td> 
                    <td id="Name"> 
                     Jim 
                    <a href="#" class="edit"> 
                      edit 
                     </a> 

                    </td> 
  </tr> 

   <tr> 
                    <td id="Name"> 
                      Remy 
                    <a href="#" class="edit"> 
                      edit</a> 
                    </td> 
  </tr> 


</table>

enter image description here

  • 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-25T01:47:32+00:00Added an answer on May 25, 2026 at 1:47 am

    first of all you should fix your html code, as the id attribute is unique. I suggest you use the class attribute:

    <table id="foo" border="1">
        <tr> 
            <td rowspan="3" class="date">Monday</td> 
            <td>Cell A1 <a href="#" class="edit">edit</a></td> 
        </tr>
        <tr> 
            <td>Cell A2 <a href="#" class="edit">edit</a></td> 
        </tr>
        <tr> 
            <td>Cell A3 <a href="#" class="edit">edit</a></td> 
        </tr>
        <tr> 
            <td rowspan="3" class="date">Tuesday</td> 
            <td>Cell B1 <a href="#" class="edit">edit</a></td> 
        </tr>
        <tr> 
            <td>Cell B2 <a href="#" class="edit">edit</a></td> 
        </tr>
        <tr> 
            <td>Cell B3 <a href="#" class="edit">edit</a></td> 
        </tr>
    </table>
    

    in the javascript code, I first check if there’s a date in the current row, if not, get the first prev. row containing a date:

    $("#foo a.edit").click(function(e){
    
        var tr = $(this).closest("tr"),
            date = tr.find("td.date");
        if (date.length == 0) {
            date = tr.prevAll(":has(td.date):first").find("td.date");
        }
    
        e.preventDefault();
        alert(date.html());
    });
    

    see a working demo at: http://jsfiddle.net/roberkules/WwZPY/

    sidenote: i noticed that you used uppercase and lowercase names for classes. I suggest to be more consistent and name them always upper or lowercase. and css classes are case sensitive, so in order to eliminate another error source, be consistent.

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

Sidebar

Related Questions

Hello I have table name FriendsData that contains duplicate records as shown below fID
I have a table as shown below. When I click a table cell(only cells
We have a configuration table as shown below that stores the start time and
I have a table as shown below Q_ID DeptID EmployeeName City 100 100 testest
I have a SQLite table called posts . An example is shown below. I
I would like to have a table header that looks like the image shown
I have sales table data as shown below Sales Table Data http://lh5.ggpht.com/_KT7tmVVBHFM/TCryAax1JlI/AAAAAAAAAFk/zahMq4RoOuw/s144/Sales.png I want
I have a table similar to the example shown below. I would like to
I have table as shown below. In order to workaround one default now column
I have a table as shown below. ID ParentID Node Name Node Type ------------------------------------------------------------------

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.