javascript get parent element by class code example
Example 1: javascript get element by class
var elementsArray = document.getElementsByClassName("someclassname");
Example 2: javascript get element by class
const whiteBoxes = document.getElementsByClassName("box-white")
Example 3: javascript node has parent with class
function hasParentClass(child, classname){
if(child.className.split(' ').indexOf(classname) >= 0) return true;
try{
return child.parentNode && hasParentClass(child.parentNode, classname);
}catch(TypeError){
return false;
}
}