Demo
Code
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script>
$(document).ready(function(){
$("#butt").click(function(){
$("#tableId tbody").append("<tr><td><input type='text' ></td><td><input type='text'></td><td><input type='text' ><img src='img.png' onClick='remove($(this));'></td></tr>");
});
});
function remove(name)
{
name.closest('tr').remove();
}
</script>
<table id="tableId">
<thead>
<tr>
<th >Sl</th>
<th >Name</th>
<th >Mark</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Name1</td>
<td>89</td>
</tr>
<tr>
<td>2</td>
<td>Name2</td>
<td>95</td>
</tr>
</tbody>
</table>
<button id="butt">Add New</button>
Sl | Name | Mark |
---|---|---|
1 | Name1 | 89 |
2 | Name2 | 95 |
Code
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script>
$(document).ready(function(){
$("#butt").click(function(){
$("#tableId tbody").append("<tr><td><input type='text' ></td><td><input type='text'></td><td><input type='text' ><img src='img.png' onClick='remove($(this));'></td></tr>");
});
});
function remove(name)
{
name.closest('tr').remove();
}
</script>
<table id="tableId">
<thead>
<tr>
<th >Sl</th>
<th >Name</th>
<th >Mark</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Name1</td>
<td>89</td>
</tr>
<tr>
<td>2</td>
<td>Name2</td>
<td>95</td>
</tr>
</tbody>
</table>
<button id="butt">Add New</button>
Comments
Post a Comment