DOM的节点
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head> <title>Title</title></head><body><!--DOM节点--><!--document object--><!--element object--><!--attribute object--><!--text object--><!--comment object--><div id="div1"> <div>hello star</div> <p>hihi p</p></div><script> var ele=document.getElementById(‘div1‘)// alert(ele)//[object HTMLDivElement// console.log(ele.nodeName);//DIV// console.log(ele.nodeType);//1// console.log(ele.nodeValue);//null// var ele1=ele.firstChild;// console.log(ele1.nodeName);//#text ---- DIV// var ele2=ele.lastChild;// console.log(ele2.nodeName);//text----P// var ele3=ele.childNodes;// console.log(ele3.length);//5 var ele3=ele.parentNode; console.log(ele3.nodeName);//BODY</script></body></html>
相关推荐
luvhl 2020-08-17
littleFatty 2020-08-16
Aveiox 2020-06-23
archimedes 2020-05-27
zhuxue 2020-10-14
zhangbingb 2020-09-21
HeronLinuxampARM 2020-09-14
美丽的泡沫 2020-09-08
goodstudy 2020-08-19
gamestart0 2020-08-15
URML 2020-08-15
sfkong 2020-08-02
82941732 2020-07-27
偏头痛杨 2020-07-18
timewind 2020-07-04
89407707 2020-06-27
xiaoxiaoCNDS 2020-06-26
lyjava 2020-06-26