Remove the ," "
from the end of the img
-creation line.
What your code is doing is attempting to do:
theImageElement.appendChild(document.createTextNode(" "));
While some browsers may allow and silently ignore this error, it is indeed an error and IE is strictly speaking correct to complain about it.
As an aside, HTML does not have self-closing tags. So <img></img>
is indeed the "correct" HTML representation of an image element, however the <img>
element is not allowed to have child nodes.