How to avoid duplication of data using jquery? My code is :
<button id="gen">Generate</button>
<table id="report" border="1" style="visibility:hidden">
<tr>
<th>Sl.No.</th>
<th>District Name</th>
</tr>
</table>
js:
$("#gen").click(function(){
$("#report").css("visibility","visible");
for(var i=0; i<5; i++){
var row='<tr><td>('+(i+1)+')</td></tr>'
$("#report").append(row);
}
});
Each time when i clicking the button, the same data were shown. How to avoid it? sqlfiddle: http://jsfiddle.net/etdx5o08/