You can only append full nodes to the dom. One solution would be to wrap the text nodes in <p>
elements and remove the <br>
s:
$('#content').contents().filter(function() {
return this.nodeType == 3 && $.trim($(this).text()).length > 0;
}).wrap('<p/>');
$('#content br').remove();