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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:30:13+00:00 2026-05-30T08:30:13+00:00

I have a table dinamically generated by a mySQL query as this: | title

  • 0

I have a table dinamically generated by a mySQL query as this:

|    title    | Published |      Delete     |
---------------------------------------------
|  Review_1   |   Yes     | click_to_delete |
|  Review_2   |   Yes     | click_to_delete |
|  Review_3   |   Yes     | click_to_delete |

Each table row is builded – for example – with the following code (id is 1 only for example):

<tr>
    <td><a class="editlink" id="1" href="#">Review_1</a><td>
    <td><input type="checkbox" /></td>
    <td><a class="delete_review" id="1" href="#"><img src="remove.png"/></a></td>
</tr>

I would like that when the user clicks – for example – the first link ‘click_to_delete’ an alert pops up saying that his is going to delete the review ‘Review_1’.

So I want to get the TEXT of the Review_1 link when the users clicks the corresponding ‘click_to_delete’.

I tried with the following code:

$(".delete_review").click(function() {
    var index = $(".editlink").index(this);
    var item_name = $(".editlink").eq(index).text();
    alert(item_name);
}

I don’t understand why this line returns correctly the position of the element

var index = $(".editlink").index(this);

while this one does not return the text of the link:

var item_name = $(".editlink").eq(index).text();

of course $(this) is not usefull in this case because the event is not fired by the same element.

  • 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-30T08:30:14+00:00Added an answer on May 30, 2026 at 8:30 am

    You can traverse the DOM tree up to the td element using closest (or parent, but bear in mind that it would then break if you happened to add more elements in between) and then use siblings and eq to get the first sibling:

    var item_name = $(this).closest("td").siblings().eq(0).text();
    

    The index method returns the index of the element relative to its siblings. In your case, the link has no siblings, so the index should always be 0.

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

Sidebar

Related Questions

I have a part of webpage that is dynamically generated using MySQL queries: <table
i have a table array dynamically generated from a data query and stored in
I'm working on a web page where I have a dynamically generated table where
I have a table of data that is generated dynamically based on the contents
Brief: Based on a query, I have multiple checkboxes generated dynamically. The value of
OK MySQL Wizards: I have a table of position data from multiple probes defined
I have a form with a dynamically-generated group of fields - backend is php/mySQL,
I have a table with some dynamically generated data. The issue is I want
How can I add a row to a dynamically-generated table but have the id
Hopefully I can explain this clearly enough. I have a table that displays some

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.