我想使用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