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
Try this :-
Some text here which is not wrapped in tags
Some more text which is fine
Blah blah another good line
JS
$(function(){
var $temp = $('');
$('div.container p').each(function(){
$(this).appendTo($temp);
});
if($.trim( $('div.container').html() ).length){
var $pTag = $('').html($('.container').html());
$('div.container').html($pTag);
}
$('div.container').append($temp.html());
});
Here is the working example :-
http://jsfiddle.net/dhMSN/12