Nav Menu Ul Li Add Active Class | Add active class to navigation menu on click


Simplest way to make a custom menu with ul li active class When a user clicks on any link, it will be highlighted, providing a smooth experience. In this tutorial, you will learn how to use HTML and CSS to show the active item in an unordered list. Whenever you create a header with multiple list menus, we need to highlight the menu link when the user clicks on it. This allows the user to detect if the menu is clicked or not and see which menu is active. With the help of JavaScript, an event listener is applied which clicks on the current LI and adds the active class to it. This is the way by which you can add the active class to the current element. You can also add CSS to the active class by using the selector ul li a.active.



This is totaly javascript tutorial no jquery involved in this.

Demo

Totaly made with javascript easy to use , To impliment Please follow the below code :

HTML FILE

JAVASCRIPT

CSS

Further reading