久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何定位平面層次結構中的特定兄弟姐妹組?

How can I target a specific group of siblings in a flat hierarchy?(如何定位平面層次結構中的特定兄弟姐妹組?)
本文介紹了如何定位平面層次結構中的特定兄弟姐妹組?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

假設你有這個 HTML:

Assume you have this HTML:

<h1>Header 1</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<h1>Header 1</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<h1>Header 1</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>

請注意,層次結構是扁平的.

Note that the hierarchy is flat.

現在嘗試選擇 <p> 元素的中間對".這可能嗎?我實在想不通.

Now try to select the "middle pair" of <p> elements. Is this possible? I really can't figure out how.

這個選擇器只抓取<h1>之后的第一個<p>:

This selector only grabs the first <p> following the <h1>:

h1:nth-of-type(2) + p

但是這個選擇器會抓取正確的一對 <p> 元素加上所有出現在后面的 <p> 元素我們想要的一對:

But this selector grabs the correct pair of <p> elements plus all the following <p> elements that appear after the pair we want:

h1:nth-of-type(2) ~ p

有可能嗎?

沒有 JavaScript.沒有標記更改.通用解決方案.允許任意數量的 <h1>s 或 <p>s,在這種情況下,數字 2 是任意的.

No JavaScript. No markup changing. Generic solution. Any number of <h1>s or <p>s are allowed, and the number two, in this case, is arbitrary.

我在想也許這可以使用一些使用 :not() 選擇器,但我似乎無法弄清楚.有點像選擇一般兄弟姐妹",然后根據需要排除,或類似的東西.

I'm thinking maybe this is possible using some using the :not() selector, but I can't seem to figure it out. Kind of like selecting the "general siblings" and then excluding as necessary, or something similar.

推薦答案

由于一般同級組合器的工作方式,不可能將同級的選擇限制在特定范圍或組中,即使是連續的同級.甚至 :not() 選擇器在這里也沒有任何幫助.

Due to the way the general sibling combinator works, it is not possible to limit a selection of siblings to a specific range or group, even of consecutive siblings. Even the :not() selector won't be of any help here.

必須使用 JavaScript 來定位正確的元素.jQuery 的 .nextUntil() 方法 立即浮現在腦海中.

You will have to use JavaScript to target the right elements. jQuery's .nextUntil() method immediately springs to mind.

這篇關于如何定位平面層次結構中的特定兄弟姐妹組?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Style every third element?(每隔三個元素設置樣式?)
Why shouldn#39;t I use ID selectors in CSS?(為什么我不應該在 CSS 中使用 ID 選擇器?)
What does img[class*=quot;alignquot;] mean in CSS?(CSS 中的 img[class*=“align] 是什么意思?)
CSS: Last element on line(CSS:最后一個元素)
How do I select every other div class element using just CSS (no js)(如何僅使用 CSS(無 js)選擇所有其他 div 類元素)
Tool for checking unused CSS selectors?(檢查未使用的 CSS 選擇器的工具?)
主站蜘蛛池模板: 国产精品美女久久久久 | 欧美白人做受xxxx视频 | 亚洲一区视频在线播放 | 亚洲精品免费在线 | 日韩欧美国产不卡 | 欧美在线a | 最近日韩中文字幕 | 欧美日韩在线精品 | ririsao久久精品一区 | 国产在线一区二区三区 | 精品国产久 | 亚洲人人| 日本在线视频一区二区 | 一区视频在线免费观看 | 热99视频| 午夜视频在线免费观看 | 夜夜久久| 成人一级片在线观看 | 国产视频1区 | 国产成人艳妇aa视频在线 | 日韩av一区二区在线观看 | 精品成人在线观看 | 欧美在线视频网 | 亚洲毛片在线观看 | 99pao成人国产永久免费视频 | 欧美 中文字幕 | 中文字幕视频一区 | 精品国产乱码久久久久久影片 | 国产欧美精品一区二区 | 国产成人99久久亚洲综合精品 | 97天天干 | 五月天天丁香婷婷在线中 | 欧美一区二区在线观看 | 性色网站 | 亚洲国产成人精品女人久久久 | 黄色一级在线播放 | 国产免费av在线 | 在线观看中文字幕视频 | 国产精品一区二 | 色视频一区二区 | 国产99久久精品一区二区永久免费 |