<body>
<table>
<tr><td></td></tr>
</table>
<table>
<tr><td></td></tr>
</table>
<div> </div>
</body>
例子 html 如上
$("table tr:first") 得到的是第一个table 中的 第一个 tr对象 ;
$("table tr:first-child") 得到的是每个table 中的 第一个 tr对象 ;
$("body table:first) 得到的是第一个table r对象 ;
$("body table:first-child) 得到的是 一个 空的 jquery 对象 并没有得到预想的第一个table,因为 body 的子标签 中 并不是 全部的table ,还有 div ,所以 就 得不到任何东西,$("table tr:first") 得到的是第一个table 中的 第一个 tr对象 是因为 table 中 直接子标签都是tr;
<table>
<tr><td></td></tr>
</table>
<table>
<tr><td></td></tr>
</table>
<div> </div>
</body>
例子 html 如上
$("table tr:first") 得到的是第一个table 中的 第一个 tr对象 ;
$("table tr:first-child") 得到的是每个table 中的 第一个 tr对象 ;
$("body table:first) 得到的是第一个table r对象 ;
$("body table:first-child) 得到的是 一个 空的 jquery 对象 并没有得到预想的第一个table,因为 body 的子标签 中 并不是 全部的table ,还有 div ,所以 就 得不到任何东西,$("table tr:first") 得到的是第一个table 中的 第一个 tr对象 是因为 table 中 直接子标签都是tr;