<a href="example.html">Any text or Image<a>
Run Code Online (Sandbox Code Playgroud)
我想使用 href 的值添加 display none 。
例如:我只想添加display: none到所有重定向到example.html. 所有其他锚标记应该仍然可见。
换句话说,我只想隐藏转到example.html.
这可能吗?
您可以使用以下解决方案,使用属性选择器:
a[href="example.html"] {
display:none;
}Run Code Online (Sandbox Code Playgroud)
<a href="example.html">Any text or Image<a>
<a href="https://stackoverflow.com/">StackOverflow<a>Run Code Online (Sandbox Code Playgroud)
a[href$="example.html"]如果href包含完整网址,您也可以使用:
a[href$="example.html"] {
display:none;
}Run Code Online (Sandbox Code Playgroud)
<a href="example.html">Any text or Image<a>
<a href="https://example.com/example.html">Any text or Image<a>
<a href="https://stackoverflow.com/">StackOverflow<a>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2988 次 |
| 最近记录: |