title: How to add nav-active class in in navigation using jquery only one time
body: <p>Please help me to sort out this problem. I want to add <code>nav-active</code> class in li element only one time means if child element is selected then parent li should not have <code>nav-active</code> class. I am using following code but it is not working according to my requirements.
  Thanks in advance.</p>
  
  <p>Here is my code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$('ul li').find('li').click(function(){
     var $this = $(this);
     $('li').removeClass('nav-active');
     $this.addClass('nav-active');
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;nav id="menu" class="nav-main" role="navigation"&gt;
   &lt;ul class="nav nav-main"&gt;
    &lt;li class="nav-parent item-b"&gt;
     &lt;a href="#"&gt;
      &lt;i class="icon icon-global" aria-hidden="true"&gt;&lt;/i&gt;
      &lt;span&gt;Global&lt;/span&gt;
     &lt;/a&gt;
  
     &lt;ul class="nav nav-children"&gt;
      &lt;li class="item-a"&gt;
       &lt;a href="#"&gt;
        &lt;span&gt;News&lt;/span&gt;
       &lt;/a&gt;
      &lt;/li&gt;
      &lt;li&gt;
       &lt;a href="#"&gt;
        &lt;span&gt;Highlights&lt;/span&gt;
       &lt;/a&gt;
      &lt;/li&gt;
     &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li class="nav-parent"&gt;
     &lt;a href="#"&gt;
      &lt;i class="icon icon-document-512"&gt;&lt;/i&gt;&lt;span&gt;My Documents&lt;/span&gt;
     &lt;/a&gt;
     &lt;ul class="nav nav-children" id="menu1"&gt;
      &lt;li&gt;
       &lt;a href="#"&gt;
        &lt;span&gt;My Download&lt;/span&gt;
       &lt;/a&gt;
      &lt;/li&gt;
      &lt;li&gt;
       &lt;a href="#"&gt;
        &lt;span&gt;My Wishlist&lt;/span&gt;
       &lt;/a&gt;
      &lt;/li&gt;
      &lt;li&gt;
       &lt;a href="#"&gt;
        &lt;span&gt;My New Documents&lt;/span&gt;&lt;/a&gt;
       &lt;/li&gt;
      &lt;/ul&gt;
     &lt;/li&gt;
     &lt;li class="nav-parent"&gt;&lt;!-- nav-expanded--&gt;
      &lt;a class=""&gt;
       &lt;i class="icon icon-marketing-material" aria-hidden="true"&gt;&lt;/i&gt;
       &lt;span&gt;Marketing Material&lt;/span&gt;
      &lt;/a&gt;
      &lt;ul class="nav nav-children" id="menu1"&gt;
       &lt;li&gt;
        &lt;a href="#"&gt;
         &lt;span&gt;Batch Download&lt;/span&gt;
        &lt;/a&gt;
       &lt;/li&gt;
       &lt;li&gt;
        &lt;a href="#"&gt;
         &lt;span&gt;Upload&lt;/span&gt;
        &lt;/a&gt;
       &lt;/li&gt;
       &lt;li&gt;
        &lt;a href="#"&gt;
         &lt;span&gt;Edit/Delete&lt;/span&gt;&lt;/a&gt;
        &lt;/li&gt;
        &lt;li&gt;
         &lt;a href="#" onClick='document.getElementById("preview-frame").src="new-uploads.html";'&gt;
          &lt;span&gt;New Uploads&lt;/span&gt;&lt;/a&gt;
         &lt;/li&gt;
         &lt;li&gt;
          &lt;a href="#" onClick='document.getElementById("preview-frame").src="revision.html";'&gt;
           &lt;span&gt;Revisions&lt;/span&gt;&lt;/a&gt;
          &lt;/li&gt;
          &lt;li&gt;
           &lt;a href="#" onClick='document.getElementById("preview-frame").src="top-download.html";'&gt;
            &lt;span&gt;Top Downloads&lt;/span&gt;&lt;/a&gt;
           &lt;/li&gt;
          &lt;/ul&gt;
         &lt;/li&gt;
  
         &lt;li&gt;
          &lt;a href="#" onClick='document.getElementById("preview-frame").src="blank.html";'&gt;
           &lt;i class="icon icon-11111" aria-hidden="true"&gt;&lt;/i&gt;
           &lt;span&gt;GML Forum&lt;/span&gt;
          &lt;/a&gt;
         &lt;/li&gt;
         &lt;li&gt;
          &lt;a href="#"  onClick='document.getElementById("preview-frame").src="index - Copy.html";'&gt;
           &lt;i class="icon icon-market-research" aria-hidden="true"&gt;&lt;/i&gt;
           &lt;span&gt;Market Research&lt;/span&gt;
          &lt;/a&gt;
         &lt;/li&gt;
         &lt;li&gt;
          &lt;a href="#"&gt;
           &lt;i class="icon icon-market-access-2" aria-hidden="true"&gt;&lt;/i&gt;
           &lt;span&gt;Market Access&lt;/span&gt;
          &lt;/a&gt;
         &lt;/li&gt;
         &lt;li&gt;
          &lt;a href="#"&gt;
           &lt;i class="icon icon-compete" aria-hidden="true"&gt;&lt;/i&gt;
           &lt;span&gt;Competetive Intelligence&lt;/span&gt;
          &lt;/a&gt;
         &lt;/li&gt;
         &lt;li&gt;
          &lt;a href="#"&gt;
           &lt;i class="icon icon-portal" aria-hidden="true"&gt;&lt;/i&gt;
           &lt;span&gt;Portal Tutorial&lt;/span&gt;
          &lt;/a&gt;
         &lt;/li&gt;
         &lt;li&gt;
          &lt;a href="#"&gt;
           &lt;i class="icon icon-new-product-launch" aria-hidden="true"&gt;&lt;/i&gt;
           &lt;span&gt;New Product Launch&lt;/span&gt;
          &lt;/a&gt;
         &lt;/li&gt;                                    
         &lt;li class="nav-parent"&gt;
          &lt;a href="#"&gt;
           &lt;i class="icon icon-portal-admin"&gt;&lt;/i&gt;&lt;span&gt;Portal Administration&lt;/span&gt;
          &lt;/a&gt;
          &lt;ul class="nav nav-children" id="menu1"&gt;
           &lt;li&gt;
            &lt;a href="#" onClick='document.getElementById("preview-frame").src="abbot-social-media.html";'&gt;
             &lt;span&gt;Social Media&lt;/span&gt;
            &lt;/a&gt;
           &lt;/li&gt;
          &lt;/ul&gt;
         &lt;/li&gt;
  
         &lt;li&gt;&lt;hr class="separator" /&gt;&lt;/li&gt;
         &lt;li&gt;&lt;a href="#"&gt;&lt;i class="fa licon-calendar" aria-hidden="true" style="font-size:24px;"&gt;&lt;/i&gt;Upcoming Events&lt;/a&gt;&lt;/li
          &gt;&lt;/ul&gt;
         &lt;/nav&gt;</code></pre>
  </div>
  </div>
  </p>