I have a situation where the following code is getting written to my page.
Some text here which is not wrapped in tags Some mor
Some mor
jQuery is bad at handling text nodes, so you'll need to do some direct DOM manipulation on this. This also uses the "trim" function.. Its on jsfiddle.
var d = $("div")[0]; for(var i=0; i" + node.textContent + ""); }