I have a few pages, and I have this nav
bar - home, page 1, page 2.
I want to make the home bar to highlight when i'm on home page, and page 1 to highlight when I'm on page 1.
I did something like this
var url = window.location.pathname;
var filename = url.substring(url.lastIndexOf('/')+1);
alert(filename);
Currently this will only alert when I'm at the home page, but not on page 1 or page 2.
I wanted to do an if statement to check current html page, if home, highlight home, if page 1 highlight page 1 nav
bar and so on.
Anyone can help on how to make it alert whenever I'm on a new html page or have better suggestion on what I'm doing?
` ` Every html file that has these tags included will essentially be linked to jsfile.js and cssfile.css. The whole point of using CSS is to simplify your styling code to one file, rather than creating a style for each individual page. So you're probably best off using just one CSS and one JS file. – Dan Chrostowski Nov 03 '14 at 08:13