1.21 gigawatts
1.21 gigawatts

Reputation: 17776

How to check if the parent node is body node?

If I want to test if an element is on the body node is checking the nodeName property accurate enough?

if (element.parentNode.nodeName.toLowerCase()==="body") {

}

Upvotes: 0

Views: 1051

Answers (1)

Dan
Dan

Reputation: 10538

Compare the references:

element.parentNode === document.body

Upvotes: 7

Related Questions