Regarding Combining Two Small Javascript Codes
<p>Basically the question is self explanitory.  I can't figure out how to combine small snippets of javascript rather than having two separate files.</p>

<p>The two codes are :</p>

<pre><code>$(function(){
    $('.navbar li').each(function(){
      if(window.location.href.indexOf($(this).find('a:first').attr('href'))&gt;-1)
        {
      $(this).addClass('active').siblings().removeClass('active');
        }
    });
});

$(function(){
    $('.dropdown-menu li').each(function(){
      if(window.location.href.indexOf($(this).find('a:first').attr('href'))&gt;-1)
        {
      $(this).removeClass('active')
        }
    });
});
</code></pre>

<p>Another question, is the first <code>$(function()</code> necessary?</p>

<p>Thanks for you help.</p>
