如何避免使用jquery重复数据? 我的代码是:避免重复使用jquery
<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);
}
});
当我点击按钮每次,被示出的相同的数据。 如何避免它? sqlfiddle: http://jsfiddle.net/etdx5o08/
ü要避免重复什么? – 2015-04-23 06:55:25
我想这就是你在说什么 - http://jsfiddle.net/etdx5o08/1/ –
请检查你更新的小提琴https://jsfiddle.net/etdx5o08/2/ –