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.
- var urls = window.location.href;
-
- var pages = urls.substr(urls.lastIndexOf('/')+1);
-
- $('ul#nav a[href*="'+pages+'"]').children().hover(function(){
- $(this).parents().css("background-color", "#FFFF33");
- });