<!DOCTYPE?HTML>
<html>
<head>
<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8">
<title>無標(biāo)題文檔</title>
</head>
<body>
<div?id="con">
??<p>javascript</p>
??<div>jQuery</div>
??<h5>PHP</h5>
</div>
<script?type="text/javascript">
??var?x=document.getElementById("con");
????????//document.write(x.firstChild.nodeName);
????????document.write(x.firstChild.nodeValue);
????????document.write(x.firstChild.nodeName);
????????document.write(x.childNodes[0].nodeName);
????????document.write(x.childNodes[0].nodeValue);
????????//document.write(x.lastChild.nodeName);
????????document.write(x.lastChild.nodeValue);
</script>
</body>
</html>
第一個子節(jié)點(diǎn)不是<p>javascript</p>嗎?為什么
????????document.write(x.firstChild.nodeName)==#text;
????????document.write(x.firstChild.nodeValue)=="";
2019-08-19
前面章節(jié)不是說了是有空白節(jié)點(diǎn)嗎,請認(rèn)真對待每一個章節(jié)
2018-12-26
因?yàn)楣?jié)點(diǎn)之間的空白符,前面章節(jié)有說過,如果你用的是火狐或者谷歌輸出文本屬性那肯定是無疑問的了,可能會問前面不是說,在firefox、chrome、opera、safari瀏覽器是文本節(jié)點(diǎn)嗎,IE不是啊,可能老版本的IE可能會輸出P,現(xiàn)在高版本的IE,節(jié)點(diǎn)間的空白符也是文本節(jié)點(diǎn)了,你可以測試節(jié)點(diǎn)個數(shù),就知道了
2018-12-19
有空白節(jié)點(diǎn)。。。