Create A Blank Html Space On The Fly Javascript
If you really just want to append a space character, use the following:
div.innerHTML += ' ';
or
div.innerHTML += ' ';
for the HTML entity.
Try using this:
myElement.appendChild( document.createTextNode( '\u00A0' ) );
If you want/need more spaces, use several \u00A0
e.g.:
myElement.appendChild( document.createTextNode( '\u00A0\u00A0' ) );
This one:
document.createEntityReference('nbsp');
doesn't work all browsers, so avoid it.