Creating dynamic table using jquery
we can create html controls dynamically when we need using jquery.This will be very helpful to bind data in table .
Jquery
var th = "<tr> <th >Country</th></tr>";
$('#tbltest thead').empty().append(th);
var tr ="";
tr += "<tr><td >India</td></tr>";
tr += "<tr><td >US</td></tr>";
tr += "<tr><td >FRANCE</td></tr>";
$('#tbltest tbody').empty().append(tr);
HTML
<table id="tbltest ">
<thead></thead>
<tbody></tbody>
</table>
Jquery
var th = "<tr> <th >Country</th></tr>";
$('#tbltest thead').empty().append(th);
var tr ="";
tr += "<tr><td >India</td></tr>";
tr += "<tr><td >US</td></tr>";
tr += "<tr><td >FRANCE</td></tr>";
$('#tbltest tbody').empty().append(tr);
HTML
<table id="tbltest ">
<thead></thead>
<tbody></tbody>
</table>
Comments
Post a Comment