jack< ;/div>
<script> <br>alert(document.getElementById('user').innerHTML.length); <br></script>
There are two English spaces before the text "jack" in div[id=user]. The results in each browser are as follows
IE6/7/8: 4 pops up, that is, the spaces are ignored
IE9/Firefox/Safari/Chrome/Opera: 6 pops up, that is, the spaces
are not ignored. Changing to Chinese spaces will not cause this problem.
The following is Gray Zhang’s addition:
1. Under IE6-8, for the firstChild of an element, if it is TextNode, and the first n characters of nodeValue are space characters (including spaces, ,
,
and a page break symbol U 000C), then these n characters are ignored
2. Under IE6-8, for the lastChild of an element, if it is TextNode, and the last n characters of nodeValue are space characters (including spaces, ,
,
and a page break symbol U 000C), then these n characters will be combined into a space (ASCII code is 32), whether you are t or n, it will become a space