[英]Delete column at jquery DataTable with javascript
I use the table plug-in for jquery Datatable at my rails app, and i look for a way to delete the whole column if some actions occurs eg if a button was clicked. 我在rails应用程序中使用用于jquery Datatable的表插件,并且我寻找一种方法,如果发生某些操作(例如,单击按钮),则删除整个列。
The table: 桌子:
<table id="words" class="display" data-source="<%= url_for controller:"words", action: "index", :format=>:json %>" >
<thead>
<tr>
<th><%= l(:name) %></th>
.
.
.
</tr>
</thead>
<tbody>
</tbody>
</table>
How can I do that? 我怎样才能做到这一点?
Ok, nth-child selector works(thx @TrueBlueAussie) for my the following way: 好的, 第n个子选择器通过以下方式工作(thx @TrueBlueAussie):
$('#words thead').find("tr th:nth-child(5)").each(function(){$(this).remove()});
$('#words tbody').find("tr td:nth-child(5)").each(function(){$(this).remove()});
It removes the 5'th column from my table. 它从我的表格中删除了第5列。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.