【发布时间】:2018-02-02 07:27:47
【问题描述】:
在这种情况下,我只想定位具有 thead 标签的表。
我尝试使用更快的 JavaScript 或 jQuery 进行连接或搜索。
例如thead = DT[i].children('thead');
function go() {
var i = 0,
DT = document.getElementsByClassName('DT');
for (i; i < DT.length; ++i) {
var x = DT[i];
if ($(x + ' thead').length) {
//do stuff to this table
}
}
}
<table class="DT" id="gv1">
<tbody>
<tr>
<th>th</th>
</tr>
<tr>
<td>td</td>
</tr>
</tbody>
</table>
<table class="DT" id="gv2">
<thead>
<tr>
<th>thead</th>
</tr>
</thead>
<tbody>
<tr>
<td>td</td>
</tr>
</tbody>
</table>
【问题讨论】:
标签: javascript jquery foreach each