Targeting child elements

Targeting child elements

Hi, I'm very new to jquery and I want to use it to highlight the top-most element (parent) in my navigation list. For instance if i'm on a specific page, and I happen to hover over one of the child elements of the page I'm on I want to be able to change the background color of the parent element that i've just hovered over. Below is the code I currently have, but isn't working.

  1.    var urls = window.location.href;
  2.    
  3.    var pages = urls.substr(urls.lastIndexOf('/')+1);
  4.    
  5.    $('ul#nav a[href*="'+pages+'"]').children().hover(function(){
  6. $(this).parents().css("background-color", "#FFFF33");
  7. });