I want to set "someting " as the html inside a div, but .html() seem to remove the trailing spaces.
It’s inside a contenteditable div, so when the users starts typing there’s a space missing between “something” and what he types.
HTML
<div id="text" contenteditable="true"></div>
JAVASCRIPT
$('div#text').html('something ');
This shows “something_” inside the div, but when you start typing it appears right next to the rest of the text.
In order to set visible spaces in HTML, they should be in the form of
, e.g.An option is to make basic spaces transformation using your own function:
DEMO: http://jsfiddle.net/NAWY3/