怎样快捷获取元素节点body

1. 使用: document.body

document.body.nodeName;
// "BODY"

 

2. 使用: document.getElementsByTagName("body")

document.getElementsByTagName("body")[0].nodeName;
// "BODY"

 

3. 使用: document.querySelector("body").nodeName

document.querySelector("body").nodeName; 
// "BODY"

 

posted on 2019-09-17 11:14  aisowe  阅读(1235)  评论(0)    收藏  举报

导航