-2
我想在使用jQuery的時候在html表格的末尾添加一列。如何使用jQuery在html表格末尾添加列?
我創建了以下HTML表格。
<table class="table table-bordered table-striped" id="reportColumns">
<thead>
<tr></tr>
</thead>
<tbody>
<tr></tr>
</tbody>
</table>
然後我說下面的jQuery代碼
$('.checkbox').click(function(){
var id = $(this).attr('data-tag');
$("#reportColumns > thead > tr").append('<th id="'+ id +'">Some Column header</th>');
$("#reportColumns > tbody > tr").append('<td>-</td>');
});
但出於某種原因,這是行不通的。沒有列被添加到表中。甚至沒有可見的表格。
我該如何解決這個問題?
有了這個分數,這些徽章,你不能讓一個最小的努力來正確地格式化你的問題?或者發佈一個MCVE? – Amit
您確定.checkbox偵聽器正在被解僱嗎? – Sergeon
@Sergeon是的。我甚至登錄到控制檯 – Jaylen