Return the text of a HREF from a list generated dynamically
<p>I have a table generated dynamically that may be represented as follows:</p>

<pre><code>&lt;a class="editlink" id="1" href="#"&gt;Entry_1&lt;/a&gt;
&lt;a class="editlink" id="2" href="#"&gt;Entry_2&lt;/a&gt;
&lt;a class="editlink" id="3" href="#"&gt;Entry_3&lt;/a&gt;
&lt;a class="editlink" id="4" href="#"&gt;Entry_4&lt;/a&gt;
&lt;a class="editlink" id="5" href="#"&gt;Entry_5&lt;/a&gt;
</code></pre>

<p>I'm unable to get the text of the HREF anchor (i.e <strong>'Entry_3'</strong>). The following returns correctly the right index:</p>

<pre><code>var index = $(".editlink").index(this);
</code></pre>

<p>but this one returns <strong>always the last</strong> element of the list:</p>

<pre><code>var item_name = $(".editlink").eq(index).text();
</code></pre>

<p><strong>$(this).text() returns nothing</strong></p>

<p><strong>$(a#3).text() returns nothing</strong> (remember also that the list is generated dinamically)</p>

<p>Thank you.</p>

<p><strong>I FOUND WHAT'S WRONG but don't know how to fix it:</strong></p>

<p>A LOOP generates the following table with a number of rows:</p>

<pre><code>&lt;tr&gt;
    &lt;td&gt;&lt;a class="editlink" id="1" href="#"&gt;Item_1&lt;/a&gt;&lt;td&gt;
    &lt;td&gt;&lt;input type="checkbox" /&gt;&lt;/td&gt;
    &lt;td&gt;&lt;a class="delete_review" id="1" href="#"&gt;&lt;img src="remove.png"/&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
</code></pre>

<p>I want to delete the row (that part works) when the user clicks the image (.delete_review):</p>

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

<p>I noticed from the examples you provided that the script works if I call JQuery using the same class of the links (.editlink);</p>

<pre><code>$(".editlink").click(function() {
</code></pre>

<p>but not if I use the class of the image:</p>

<pre><code>$(".delete_review").click(function() {
</code></pre>
