Looking at href values of children

Looking at href values of children

Hello!

I am trying to apply a specific class to an ID if the href values of any of the children are equal to the current URL, in this case a list of links in a menu.  Here is a part of the relevant HTML and the jquery code I am trying.  Any help will be greatly appreciated!!

  1.  <!-- notice the ID on the li - "aboutsection" -->
  2. <ul id="mainnav" class="nav navbar-nav">
  3.    
  4.             <!-- About -->
  5.             
  6.            
  7.             <li class="dropdown jsb-fw" id="aboutsection"><a href="#" 

  8. data-hover="dropdown" data-delay="100" data-close-others="false" 

  9. class="dropdown-toggle">About</a>
  10.               <ul class="dropdown-menu">
  11.             
  12.               <li class="grid-output">
  13.              
  14.                 <div class="row">
  15.                
  16.               <div class="col-sm-3 about">
  17.              
  18.                     <h3 class="menuHeading">About US</h3>
  19.                  <ul>
  20.                        <li><a 

  21. href="http://localhost:8500/mysite/pagetestcurrent.cfm">About this page</a></li>
  22.                        <li><a 

  23. href="http://localhost:8500/mysite/anotherpage.cfm">About another page </a></li>
  24.                                     
  25.                    </ul>
  26.        </div>
  27.       </div>
  28.              </li>
  29.            </ul>
  30.         </li>   

  31.   </ul>

  32. <!-- if we are on any of the pages in the dropdown menu (which would 

  33. be either'pagetestcurrent' or 'anotherpage' as in the example above as 

  34. children of the about section), put a currentTab class on the above li 

  35. with the ID 'aboutsection'-->

  36. The jquery I am trying is this, but no luck - 

  37. <script>
  38. $('#aboutsection a').filter(function(){
  39. var currentURL = window.location.href;
  40.    if
  41.    (
  42.     currentURL == $(this).children('a').attr('href')
  43.     {
  44.        $('#aboutsection').addClass('currentTab');
  45.    }
  46.   
  47. )};


  48. </script>