jQuery :nth-of-type() 选择器

jQuery 教程 · 2019-03-10 09:14:23

实例

选取属于其父元素的第三个 <p> 元素的每个 <p> 元素:

$("p:nth-of-type(3)")

定义和用法

:nth-of-type(n) 选择器选取属于其父元素的特定类型的第 n 个子元素的所有元素。

提示:请使用 :nth-child() 选择器来选取属于其父元素的不限类型的第 n 个子元素的所有元素。

语法

:nth-of-type(n|even|odd|formula)

参数 描述
n 要匹配的每个子元素的索引。

必须是一个数字。第一个元素的索引号是 1。
even 选取每个偶数子元素。
odd 选取每个奇数子元素。
formula 规定哪个子元素需通过公式 (an + b) 来选取。
实例:p:nth-of-type(3n+2) 选取每个第三段,从第二段开始。

点击查看所有 jQuery 教程 文章: https://codercto.com/courses/l/35.html

查看所有标签

Implementing Responsive Design

Implementing Responsive Design

Tim Kadlec / New Riders / 2012-7-31 / GBP 27.99

New devices and platforms emerge daily. Browsers iterate at a remarkable pace. Faced with this volatile landscape we can either struggle for control or we can embrace the inherent flexibility of the w......一起来看看 《Implementing Responsive Design》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具