Son*_*Boy 2 jquery css-selectors
我有一点jQuery问题.我在页面上有多个表,它们都具有相同的类但没有ID.我希望能够从所有表中获得第一行.是否有捷径可寻?
这是我到目前为止所得到的:
$(.t13Standard tr:first')
Run Code Online (Sandbox Code Playgroud)
但是,它只选择第一个表中的第一行.从所有表中获取第一行的任何方法?
你需要使用nth-child()或first-child():
$('.t13Standard tr:first-child')
Run Code Online (Sandbox Code Playgroud)
要么
$('.t13Standard tr:nth-child(1)')
Run Code Online (Sandbox Code Playgroud)
伪选择器:first,:eq(),:gt()等是在所执行的结果相对于其他元件没有设置.
选择器:first-child,:last-child,:nth-child()在相对于所述元件执行.