JQuery: how to create a double.not () statement?
I have 3 layers of nested menus in <ul>
s, for example:
<div id="menu">
<ul>
<li><a href="somewhere.html">enu Item</a>
<ul>
<li><a href="somewhere.html">Menu Item 2</a>
<ul>
<li><a href="somewhere.html">Menu Item 3</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
I want to use Jquery to replace the first level href attribute ul
with #, but keep the href attributes in the 2nd and 3rd tags.
Ive created this script that works for 2nd level ul
but not 3rd level.
$("#menu ul li a").not("#ctamenu ul li ul a").attr("href", "#");
I've tried this:
$("#menu ul li a").not("#menu ul li ul a").not("#menu ul li ul li a").attr("href", "#")
But it doesn't work - on the third level there is href='#'
Is there a way to make the expression "double not"?
+3
source to share
2 answers