Skip to content Skip to sidebar Skip to footer

Active Link On Javascript Menu To Work On Parent Link Not Just Child Link

I am trying to finish up my navigation for my site. I'm attaching the jsfiddle code to show you what code I have now. My problem is my child links become gray when they are suppo

Solution 1:

Look at this JSFiddle.

$('#nav li a').click(
   (...)

   // Here I removed the "active" class from all siblings "li"
   $(this).parent().siblings().removeClass("active");

   (...)

   // Here I add the "active" class to this "li"
   $(this).parent().addClass("active");

   (...)
)

Note 1: The new JSFiddle

Post a Comment for "Active Link On Javascript Menu To Work On Parent Link Not Just Child Link"