How to Delete a Row in Table using jQuery.

 Posted by Vishalneeraj-24503 on 3/1/2015 | Category: Interview Questions Interview questions | Views: 426 | Points: 40
Answer:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>

<script type="text/javascript">
$(function() {
$('input[type="button"]').click(function(e) {
var row = $(this).closest('tr');
row.remove()
})
})
</script>

<div>
<table>
<tr>
<td><input type="button" value="Delete Row1"/></td>
</tr>
<tr>
<td><input type="button" value="Delete Row2" /></td>
</tr>
<tr>
<td><input type="button" value="Delete Row3"/></td>
</tr>
</table>
</div>


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response