我想在表格中插入一個動態行。顯然,我能夠添加輸入行,但我無法爲按鈕<td class="text-center"><a class='btn btn-info btn-xs' href="#"><span class="glyphicon glyphicon-edit"></span> Select</a> </td>
添加新行。它給出了Uncaught SyntaxError: missing) after argument list
動態表格行創建
<table id="tab_logic" class="table table-bordered table-striped display nowrap" cellspacing="3" width="100%">
<br>
<thead>
tr>
<th>Name</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr id='addr0'>
<td>1
</td>
<td class="text-center"><a class='btn btn-info btn-xs' href="#"><span class="glyphicon glyphicon-edit"></span> Select</a> </td>
</tr>
<tr id='addr1'></tr>
</tbody>
<tfoot>
</tfoot>
</table>
錯誤的Javascript
<script type="text/javascript">
$(document).ready(function(){
var i=1;
$("#add_row").click(function(){
$('#addr'+i).html("<td>"+ (i+1) +"</td><td><input name='name"+i+"' type='text' placeholder='Name' class='form-control input-md' /> </td> <td class="text-center"><a class='btn btn-info btn-xs' href="#"><span class="glyphicon glyphicon-edit"></span> Select</a> </td>");
$('#tab_logic').append('<tr id="addr'+(i+1)+'"></tr>');
i++;
});
});
</script>
刪除$(文件)。就緒(函數(){你的沒必要 – 2017-02-25 07:44:47