如果<a> tag carries #

时间:2015-09-28 13:11:46

标签: css css3

For a project, I've got a dynamic megamenu.

In primary menu I have <a> tag which have URL & #. I need to assign cursor:pointer as cursor:default for the <a> tag which carries href="#".

Is there any possibilities to control using css

<ul>
  <li><a href="#">Dummy</a></li>
  <li><a href="url.htm">Dummy</a></li>
  <li><a href="url.htm">Dummy</a></li>
</ul>

1 个答案:

答案 0 :(得分:5)

通过在a标签上使用属性选择器,您可以轻松地检测哪些链接在其href中包含#。

从那里,您只需应用cursor: default样式即可获得所需的结果。

a[href="#"] { cursor: default }
<ul>
  <li><a href="#">Dummy</a></li>
  <li><a href="url.htm">Dummy</a></li>
  <li><a href="url.htm">Dummy</a></li>
</ul>