【发布时间】:2016-11-10 02:13:48
【问题描述】:
我想使用 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?
-
属性 != 类型。
标签: html css css-selectors