For a website I am trying to create I would like to utilize Javascript to save some duplication of work. I have an include file (siteNav.html) that contains the main website navigation tabs and would like the "active" tab to display as bold. I'm not sure how to accomplish this since I'm a Javascript newbie, but I'm looking for smething much simpler than the examples I've been coming across. Any help would be appreciated.
To begin I just want to manually identify the current page within the html; in the example of home.html it could be by adding something like the following near the top of the page...
var thisPage = home;
Then in siteNav.html (the page to be included) I would like something that would look for the variable "thisPage" and add "Active" to the end of class="tab" if the variable equals home so it would become class="tabActive".
Here's how that part looks in straight Java code.....
class="tab<%= strThisPage.equals("home") ? "Active" : "" %>">Home</a>
The above Java code basically says -- make the class "tabActive" for the home tab if the var at the top of the page equals "home", or else leave it as is (class="tab").
I need to do this in Javascript.
Thanks for any assistance and my apologies if this has been addressed in another thread.
To begin I just want to manually identify the current page within the html; in the example of home.html it could be by adding something like the following near the top of the page...
var thisPage = home;
Then in siteNav.html (the page to be included) I would like something that would look for the variable "thisPage" and add "Active" to the end of class="tab" if the variable equals home so it would become class="tabActive".
Here's how that part looks in straight Java code.....
class="tab<%= strThisPage.equals("home") ? "Active" : "" %>">Home</a>
The above Java code basically says -- make the class "tabActive" for the home tab if the var at the top of the page equals "home", or else leave it as is (class="tab").
I need to do this in Javascript.
Thanks for any assistance and my apologies if this has been addressed in another thread.