I am working on a menu that has 2 submenus. I want to use jQuery to highlight the item when it is hovered over. However, I am struggling with how to also highlight the parent item when the cursor is on the child item. The class I am using for highlighting is called "vertical-active":
.vertical-active {
background:#0F6;
}
The jQuery function I have so far looks like this:
$(document).ready(function (e) {
$('.submenu a').hover(
function () {
$(this).addClass('vertical-active');
$(this).parent('.vertical-links a').addClass('vertical-active');
},
function () {
$(this).removeClass('vertical-active');
$(this).parent('.vertical-links a').removeClass('vertical-active');
});
});
The issue seems to be with the parent selector, and I am unsure of how to correctly select the parent item of the submenu.
JSFiddle link:http://jsfiddle.net/6g9tZ/4/