Jquery: how to create double .not() statement?

attributes, javascript, jquery, jquery-selectors

Solution

The third level is nested in yet another `ul` that you are missing, but it would be easier to use the child selector:

#menu > ul > li > a

Problem

I have 3 layers of nested menus in `<ul>`s, eg: ``` <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 href attribute of the first level of `ul`s with #, but keep the href attributes on the 2nd and 3rd a tags. Ive created this script which works for 2nd level `ul`s but not the third level. ``` $("#menu ul li a").not("#ctamenu ul li ul a").attr("href", "#"); ``` I have tried this: ``` $("#menu ul li a").not("#menu ul li ul a").not("#menu ul li ul li a").attr("href", "#") ``` But this doesnt work - the 3rd layer still has `href='#'` Is there a way to do a "double not" statement?

Original source