Active Menu Script
var path = window.location.href;
$("a").each(function() {
var href = $(this).attr('href');
if (path == href) {
$(this).addClass('active');
}
});
// Option Two if there are special characters being used for foreign pages
var url = window.location.pathname;
urlRegExp = new RegExp(url.replace(/\/$/, '') + "$");
$("a").each(function() {
if (urlRegExp.test(this.href.replace(/\/$/, ''))) {
$(this).addClass('active');
}
});
$("a").each(function() {
var href = $(this).attr('href');
if (path == href) {
$(this).addClass('active');
}
});
// Option Two if there are special characters being used for foreign pages
var url = window.location.pathname;
urlRegExp = new RegExp(url.replace(/\/$/, '') + "$");
$("a").each(function() {
if (urlRegExp.test(this.href.replace(/\/$/, ''))) {
$(this).addClass('active');
}
});
Comments
Post a Comment