css獲取父元素下第幾個元素出坑和JQuery通過index()獲取下標出坑方法

這裏首先要區分nth-of-type(n)和nth-child(n)的區別: nth-of-type(n) 選擇器匹配屬於父元素的 特定類型 的第 N 個子元素的每個元素. nth-child(n) 選擇器選取父元素的第 N 個子元素, 與類型無關 寫個demo理解: <div class="container"> <div>div1</div> <p>p1</p>
相關文章
相關標籤/搜索