$(".textareashow").each(function(i){ var content = $.trim($(this).text()); var newcontent = content.replace(/ /g,'<br/>'); $(this).html(newcontent); });