I know that it is better to manage spacing by means of css rules, but how can I insert spaces between word using jQuery? Consider the following script (see it on JSfiddle) that does not work as expected (spaces are not inserted):
html:
<div id='div1'>
<span>hello</span>
</div>
js:
$("<span>my</span> ").insertAfter($("#div1").children("span").eq(0));
$("<span>friends</span> ").insertAfter($("#div1").children("span").eq(1));
alert($("#div1").html());