How to add active class to nav link ?
I want to use active class to denote current page is active : I have following folder structure hader file containing nav bar: header.php Lets say i have home.php admin.php ... etc. inside home.php i used require_once('header.php'); to include nav bar and same to each and every others page. So whenever i clicked the any nav item that active class must be appiled. I inserted JS code below and it works fine if i links goes no where but whenever i added the actual link for another page it lasts for few seconds and gone. So how to solve it. It isn't working because each time new page is loaded so it won't know the previous state to new page. So to make it working what should i do ? I haven't learned localstorage of js will it helps ? (If you haven't understand please check the post inserted with this question) JS code link: https://code.sololearn.com/WLkSKi4c1Lp9/?ref=app Post with full story: https://www.sololearn.com/post/721177/?ref=app