Sunday 28 July 2013

Add Row Dynamically in Table Using JQuery

Below code is used to add the row dynamically to table using JQuery.

How to find the row in tbody inside the Table using Jquery : 
$(‘#Search_table’).find("tbody").find("tr");

<table id="Search_table">
<thead>
<tr><td>USER ID</td>
<td>USER NAME</td>
<td>CURRENT POINT</td>
<td>ADD POINT</td>
<td>ADD DESCRIPTION</td>
<td>ACTION</td>
</tr>
 </thead>
<tbody> </tbody>
</table>

<script>
$(document).ready(function ()
{      
var table_tr="<tr><td>RajeshG</td><td>Rajesh
</td><td>100</td><td>100</td><td>
point added </td><td>ACTION </td></tr>";

$('#Search_table').find("tbody").append(table_tr);
//to append the tr in the tbody tag                  
});
</script>