如何在jQuery中列出所有表头?我的HTML表格如下。
<table class="edit-table mobile-optimised break-words">
<thead>
<tr>
<th scope="col">Location</th>
<th scope="col">Date from/to</th>
<th scope="col">Qty of<br>places</th>
<th scope="col">Paid by £155.00 voucher<br>(net value)</th>
<th scope="col">Paid by card<br>(net value)</th>
</tr>
</thead>
<tbody>
<tr class="no-records"><td colspan="5">No records to display.</td></tr>
</tbody>
</table>
我想遍历每个<th>
并获取每个文本的值。
答案 0 :(得分:6)
答案 1 :(得分:3)
$("table.edit-table thead tr th").each(function(){
console.log($(this).text());
});
答案 2 :(得分:0)
我只想在这里添加一件事。像这样在您的tr中添加类:
Omit