javascript - Check if div is descendant of another -


best way find out if element descendant of another there question, similiar 1 jquery.

so, how do in js ? have divs a, b, c, d nested in order. also, not sure if matters, there a, b, c... , another. not single element. there many same id/class.

so want see if d has parent(no matter how deep nested, long there parent on top ok) called a.

edit: also, had idea check childnodes of "a" , see if "d" 1 of them, couldnt implement it. if can working, itd awesome.

// x element checking while (x = x.parentelement) {      if (x.id == "a") console.log("found"); } 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -