我想使用css選擇包含屬性data-result="INVALID"
的段落<p>
的第一個匹配項。選擇具有數據屬性的第一個元素
我已經嘗試過這個小腳本沒有任何成功。沒有元素被選中。
我只限於此解決方案的CSS(沒有jQuery)。有沒有解決這個問題的方法?
p[data-result="INVALID"]:first-of-type {
color: red;
}
<p data-result="VALID"><b>Note:</b> a:active MUST come after a:hover in the CSS definition in order to be effective.</p>
<p data-result="INVALID"><b>Note:</b> a:hover MUST come after a:link and a:visited in the CSS definition in order to be effective.</p>
<p data-result="INVALID"><b>Note:</b> a:hover MUST come after a:link and a:visited in the CSS definition in order to be effective.</p>
難道沒有的jQuery也意味着沒有普通的JavaScript? – Damon
屬性!=類型。 – CBroe