I have a menu with multiple ul items. What i want is change the color of top menu text to red.
However this only works when i click in the first item, not in the children items.
For example, i want to click in hydrotherapy and change to red the word Services. The parent. Any idea?
$("nav.menu>ul>li").children().click(function() {
alert("asd");
var item1 = $(this),
primeira_ul = item1.closest('.menu>ul#nav>li>a.t2');
item1.addClass('font_red');
return false;
});
You can search for the first child of
$(this)that is anatag. Note that$(this)refers not to the event source, but the$("nav.menu>ul>li")element which is already your top levelli.You probably also want to unset the siblings.
JS Fiddle