nodeValue獲取Text或Comment元素的文本值.
在IE6、IE7、IE8中游覽器會自作聰明的去掉前面的空白字符text,而其他現代遊覽器則會保留空白
<body>
<span name="span">span</span>
<p> 12345 <span> 678 </span></p>
<script type="text/javascript">
var text = document.getElementsByTagName('p')[0].firstChild.nodeValue;
alert(text.length);//IE6\IE7\IE8 6 else 7
</script>
</body>
你會發現p標籤和span標籤的第一空白都沒有了.所以在html中空白最好使用html實體