title: Unable set active class to Main dropdown Menu
body: <p>index.cshtml </p>
  
  <pre><code>&lt;div class="container"&gt;
      &lt;div class="navbar-collapse collapse"&gt;
          &lt;ul class="nav navbar-nav" style="margin-left:-27px"&gt;
              &lt;li class="dropdown"&gt;
                  &lt;a class="dropdown-toggle" data-toggle="dropdown" href="#"&gt;PAGE1&lt;/a&gt;
                  &lt;ul class="dropdown-menu"&gt;
                      &lt;li&gt;@Html.ActionLink("TEST1", "Index", "TEST1")&lt;/li&gt;
                      &lt;li&gt;@Html.ActionLink("TEST2", "Index", "TEST2")&lt;/li&gt;
                  &lt;/ul&gt;
              &lt;/li&gt;
              &lt;li&gt;@Html.ActionLink("PAGE2", "Index", "PAGE2")&lt;/li&gt;
          &lt;/ul&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;script type="text/javascript"&gt;
      $(document).ready(function() {
          $('ul.nav.navbar-nav').find('a[href="' + location.pathname + '"]')
              .closest('li').addClass('active');
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>Script is working perfect for simple <code>li</code> but not for <code>&lt;a class="dropdown-toggle"</code> any help to <code>correct script</code> ?</p>
  
  <p>actually when i clicked on <code>main menu PAGE1</code> it is <code>not executing script</code> , when I clicked in <code>sub menu TEST1</code> it is <code>executing script</code>and <code>location.pathname</code> is <code>/TEST1</code> but how do I make <code>main menu as active</code> ?</p>