title: jQuery only add class if element exists
body: <p>How could I adapt the code below to work as its needed?</p>
  
  <p>At the moment <code>.active</code> adds to both the home <code>&lt;a&gt;</code> tag and services <code>&lt;a&gt;</code> tag. But I only want it to add if <code>.submenu</code> exists</p>
  
  <p><strong>html</strong></p>
  
  <pre><code>&lt;ul&gt;
  &lt;li&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="#"&gt;Services&lt;/a&gt;&lt;div class="submenu"&gt;menu contents&lt;/div&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p><strong>jQuery</strong></p>
  
  <pre><code>$(document).ready(function(){
      $('.nav li').mouseenter(function(){
          $(this).find('a').addClass('active');
          $(this).find('.submenu').fadeIn();
      }).mouseleave(function(){
          $(this).find('.submenu').stop().fadeOut();
          $(this).find('a').removeClass('active');
      });
  });
  </code></pre>