Best way to find out if element is a descendant of another there is another question, very similiar to this one but its jquery.
so, how do I do it in js ? I have di
// x is the element we are checking while (x = x.parentNode) { if (x.id == "a") console.log("FOUND"); }