从多个表中选择第一行 [英] Selecting first row from multiple tables

查看:131
本文介绍了从多个表中选择第一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jQuery问题。我有一个页面上的多个表,都有相同的类,但没有ID。我想能够从所有表中获得第一行。有没有简单的方法来做到这一点?

I've got a bit of a jQuery problem. I've got multiple tables on a page that all have the same class but no ID. I'd like to be able to be able to get the first row from all of the tables back. Is there an easy way to do this?

这是我到目前为止:

$(.t13Standard tr:first')

从第一个表的第一行。

But that only selects the first row from the first table. Any way to get the first row from all the tables?

推荐答案

你需要使用 nth-child () first-child()

$('.t13Standard tr:first-child')

$('.t13Standard tr:nth-child(1)')

伪选择器:first :eq() result 设置不与其他元素相关。

The pseudo selectors :first, :eq(), :gt() etc are performed on the result set not in relation to other elements.

选择器:first-child :last-child :nth- child()是相对于元素执行的。

The selectors :first-child, :last-child, :nth-child() are performed in relation to the elements.

这篇关于从多个表中选择第一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆