Javascript – Dynamically adding an “active” class to the nav

In your navigation menu, you would like to dynamically add an “active” class to each menu item when you’re on the corresponding pages so you can style those menu items.

 

HTML:

 

Javascript: