My code:
<div id="box">
<p>
123
</p>
<p>
abc
</p>
</div>
<script>
var html = document.getElementById("box").innerHTML;
for (var i = 0, len = html.length; i < len; i++) {
var word = html.charAt(i)
alert("_" + word + "_" + i) //Attention!! when the "i" == 0
if (i == 0) {
alert(word==" ") // it is false.....
}
}
</script>
Using API : “chatAt” ,how to write I could know the code of HTML is changing new lines…..(word == what????)
Is that you’re looking for?