Javascript 多条件属性选择器
我有一些故事的链接,有些是pdf格式的,有些是特别版的。特别版在其href中以特别版作为前缀 这是我的应用程序的简化html部分Javascript 多条件属性选择器,javascript,html,css,Javascript,Html,Css,我有一些故事的链接,有些是pdf格式的,有些是特别版的。特别版在其href中以特别版作为前缀 这是我的应用程序的简化html部分 <div class='container-node'> <a href='1.pdf'>Story 1</a> <a href='2.pdf'>Story 2</a> <a href='3.pdf'>Story 3</a> <a href='special-editio
<div class='container-node'>
<a href='1.pdf'>Story 1</a>
<a href='2.pdf'>Story 2</a>
<a href='3.pdf'>Story 3</a>
<a href='special-edition1.pdf'>Special Edition 1</a>
<a href='4.pdf'>Story 4</a>
<a href='special-edition2.pdf'>Special Edition 2</a>
</div>
您可以简单地将属性选择器与另一个not属性选择器组合使用,如下所示
a[href$=".pdf"]:not([href*="special-edition"]){
background-color: #ADD8E6 ;
}
a[href$=”.pdf“]:不是([href*=“特别版”]){
背景色:#添加8e6;
}
.容器节点{
背景色:#32CD32;
}
a[href$=".pdf"]:not([href*="special-edition"]){
background-color: #ADD8E6 ;
}