[Update code again] I have the following code:
var header_url = window.location.href;
if(/index/.test(header_url)||/home/.test(header_url)){
$('#home').addClass('select');
} else if(/about/.test(header_url)) {
$('#about').addClass('select');
} else if(/contact/.test(header_url)) {
$('#contact').addClass('select');
}
The code is work, when I click them:
http://example.com/index.html
http://example.com/about.html
http://example.com/contact.html
But if I want to add another page, set it as default main page without url, like this:
http://example.com
I try to add code but it doesn't work:
else if(/.test(header_url)) {
$('#default').addClass('select');
}
Can anybody help please? thx!
defaultcase inswitchelseat the end and use it fordefaultcase