如何选择相同类型的第n个元素 [英] How to select nth element of the same type

查看:118
本文介绍了如何选择相同类型的第n个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从所有td中选择第n个td,我该怎么做?

I would like to select the nth td from all of the td, how do I do that?

我知道我可以用document.querySelectorAll("td")[nth]做到这一点,但是我正在寻找一种纯CSS方式.

I know I can do it with document.querySelectorAll("td")[nth], but I'm looking for a pure css way.

我尝试了document.querySelectorAll("td:nth-child(77)"),但没有像document.querySelectorAll("td")[77]那样给出结果.

I tried document.querySelectorAll("td:nth-child(77)"), but it doesn't give the result as document.querySelectorAll("td")[77] does.

推荐答案

我知道我可以用document.querySelectorAll("td")[nth]做到这一点,但是我正在寻找一种纯CSS方式.

I know I can do it with document.querySelectorAll("td")[nth], but I'm looking for a pure css way.

没有纯CSS等效项.请参阅>匹配第一个/第n个整个文档中某种类型的元素

There is no pure CSS equivalent. See Matching the first/nth element of a certain type in the entire document

这篇关于如何选择相同类型的第n个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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