I am trying to match a substring of elements value to the url, in order to dynamically highlight the page the user is on.
I am positive that I have an array object of elements. I tested it in the window. Yet, I am getting an error includeArray.filter
is not a function. Here is my code
var url = window.location.href;
url = url.replace("-", " ");
var includeArray = document.getElementsByClassName("includeHelper");
var subStringElem = includeArray.filter(function (obj) {
var thisVal = obj.value
if (url.indexOf(thisVal) != -1) {
return true;
}
else { return false; }
});
What could I be doing incorrectly?