HTML
<table id='t'>
<tr>
<td id='foo' class='a b c'>blah</td>
<td id='bar' class='a c'>bloo</td>
<td id='zip' class='a b c'>blop</td>
</tr>
</table>使用jQuery,为什么下面的children调用返回0
$('#t').children('tr').length但是find返回1?
$('#t').find('tr').length发布于 2016-10-21 15:38:58
因为如果不添加tbody元素,浏览器会自动添加。
console.log($('#t').children().get(0).tagName);<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table id='t'>
<tr>
<td id='foo' class='a b c'>blah</td>
<td id='bar' class='a c'>bloo</td>
<td id='zip' class='a b c'>blop</td>
</tr>
</table>
https://stackoverflow.com/questions/40180480
复制相似问题