Dynamically replaced row in table shows error with already present rows
<p>My html contains a table have the structure like this</p>

<pre><code>&lt;table id="sample"&gt;
 &lt;tr class="new_input_field"&gt;
   &lt;td&gt;&lt;input type="text" class="first_input" /&gt;&lt;/td&gt;
   &lt;td&gt;&lt;input type="text" class="second_input" /&gt;&lt;/td&gt;
   &lt;td&gt;&lt;a href="#" class="first_link"&gt;Button1&lt;/td&gt;
   &lt;td&gt;&lt;a href="#" class="second_link"&gt;Button2&lt;/td&gt;
 &lt;/tr&gt;&lt;tr class="new_input_field"&gt;
   &lt;td&gt;&lt;input type="text" class="first_input" /&gt;&lt;/td&gt;
   &lt;td&gt;&lt;input type="text" class="second_input" /&gt;&lt;/td&gt;
   &lt;td&gt;&lt;a href="#" class="first_link"&gt;Button1&lt;/td&gt;
   &lt;td&gt;&lt;a href="#" class="second_link"&gt;Button2&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr class="new_input_field"&gt;
   &lt;td&gt;&lt;input type="text" class="first_input" /&gt;&lt;/td&gt;
   &lt;td&gt;&lt;input type="text" class="second_input" /&gt;&lt;/td&gt;
   &lt;td&gt;&lt;a href="#" class="first_link"&gt;Button1&lt;/td&gt;
   &lt;td&gt;&lt;a href="#" class="second_link"&gt;Button2&lt;/td&gt;
 &lt;/tr&gt;
&lt;/table&gt;
</code></pre>

<p>And for each row in my jquery the values for first_input and second_input value change triggers a call to server and that row will be replaced by like this.</p>

<pre><code>&lt;tr id="AIK"&gt;
&lt;td&gt;some content&lt;/td&gt;
&lt;td&gt;some other content&lt;/td&gt;
&lt;td&gt;&lt;a href="#" class="first_link"&gt;Button1&lt;/td&gt;
&lt;td&gt;&lt;a href="#" class="second_link"&gt;Button1&lt;/td&gt;
&lt;/tr&gt;
</code></pre>

<p>My Problem is when i click the buttons in dynamically replaced row should show alert. I gave jquery </p>

<pre><code>$('#sample tr td a.first_link').click(function () {
 trid = $(this).closest('tr').attr('id');
 if(trid.length &gt; 0) { alert("Swap out will come soon"); }
});
</code></pre>

<p>This works fine for newly replaced row and shows error with remaining two rows as </p>

<pre><code>TypeError: Result of expression 'trid' [undefined] is not an object.
</code></pre>

<p>The buttons should be enable for newly replaced rows only. How can i solve this? </p>
