jQuery :first-of-type 选择器
定义和用法
:first-of-type 选择器会选择其父元素下的所有特定类型的第一个子元素。
提示: 这与 :nth-of-type(1) 相同。
提示: 使用 :last-of-type 选择器来选择其父元素下的特定类型的最后一个子元素。
语法
$(":first-of-type")
亲手尝试 - 示例
选择所有 <div> 元素下的第一个 <p> 元素
如何选择所有 <div> 元素下的第一个 <p> 元素。
:first, :first-child 和 :first-of-type 之间的区别
显示 :first, :first-child 和 :first-of-type 选择器之间的区别。