http://jsfiddle.net/QNs8s/8/
Using `innerText` or `innerHTML` causes the space after an element to be erased, e.g. if you take
"this is some <span id="field"></span> inline text"
and apply
innerText
to that span, you get"this is some <span id="field">more</span>inline text"
which renders as
this is some moreinline text"
The solution is to start with something inside the span, e.g.
"this is some <span id="field"> </span>inline text"
I can't believe I've never come across this before, but googling didn't turn up anything about it. Another irritation for supporting old IE.
I hope that the indicated problem does not interfere with my artificial intelligence in JavaScript.
ReplyDelete