You can do it:
$(function() {
$.get('files/james.txt', function(data) {
data = data.split("\n");
var html;
for (var i=0;i<data.length;i++) {
html+='<p>'+data[i]+'</p>';
}
$('.disease-details').html(html);
}, 'text');
});
The above text breaks to the next line (text "formatting") and wrap each piece in <p>.. </p>. Exactly as requested.
source
share