How do you exclude an element from a jQuery function that is included in the selector?
<p>I am making a dropdown menu and am trying to make the list items image change from a plus (when not opened) to a minus (when opened).</p>

<p>The first Tier (parent list items) are set to <code>list-style:none;</code> so when the <code>.click()</code> below executes, I want the <code>.addClass('close');</code> to apply to everything EXCEPT the parent <code>&lt;li&gt;</code>'s...</p>

<p>The issue is, the selector used in the encompassing <code>.click()</code> function includes the parent list items.</p>

<p>What I need to do is say:</p>

<p><strong>"Apply the class 'close' to $(this) EXCEPT the first (parent) <code>&lt;li&gt;</code>'s'"</strong></p>

<p>Here is the jQuery:</p>

<pre><code>$(document).ready(function(){

  $("#nav li").click(function(event){

    // My attempt (not working)...
    $(this).not("#nav &gt; ul &gt; li").addClass('close');

    event.stopPropagation();
    $(this).children("ul").slideToggle(100);

    $(".last, a").click(function(event){
      event.stopPropagation();
    });

  });

});
</code></pre>

<p>And the <strong>jsFiddle</strong>:</p>

<p><a href="http://jsfiddle.net/hExC3/1/" rel="nofollow">Click to View</a></p>

<p>So my attempt was the following:</p>

<pre><code>$(this).not("#nav &gt; ul &gt; li").addClass('close');
</code></pre>

<p>That didn't work... So if anyone has any advice, it would be greatly appreciated! thanks :)</p>

<p><strong>Update:</strong></p>

<p>The class 'close' needed <code>!important</code> added to it. The jQuery was doing what it should. I will post an answer when I successfully remove the class upon closing the menu item.</p>

<p><strong>Update (2):</strong></p>

<p>Removed <code>!important</code> and changed class specification to <code>#nav li.close</code>. Thanks Adeneo!</p>

<p><strong>Update (3):</strong></p>

<p>Changed <code>.addClass()</code> to <code>.toggleClass()</code>. Seems to make this menu do what I wanted it to :) Thanks Sushanth -- for this suggestion!</p>
