/******************************
*
*
* add current-cat class
*
*
******************************/
var page_url = window.location.href;
var modified_url;
if (page_url.slice(-1) == "/") {
modified_url = page_url;
} else {
modified_url = page_url + "/";
}
var page_anchor = document.querySelectorAll(".js_c_selector a");
var href_url;
var archive_menu = addCurrentClass(page_anchor);
function addCurrentClass(elm) {
Array.prototype.forEach.call(elm, function (e) {
if (e.href.indexOf("#anchor_target") !== -1) {
href_url = e.href.replace("#anchor_target", "");
} else {
href_url = e.href;
}
if (modified_url.indexOf(href_url) !== -1) {
e.classList.add("current_cat");
}
});
return false;
}
.js_c_selector が付与されている要素内に限定