Skip to content Skip to sidebar Skip to footer

Newline Is Being Printed As A Whitespace In Text Area Of Html. How Do I Resolve

This is my small jquery script where I append data that I receive. $.get('HelloWorld', {'data' : data}, function(newLogs) { $('#logsid').append(newLogs); $('#logsid').scrol

Solution 1:

By default, HTML renders newlines as spaces (and multiple whitespace is collapsed to one space). Add this rule to your stylesheet to preserve whitespace...

#logsid {
    white-space: pre;
}

Or you can do this in jQuery...

$('#logsid').css("white-space", "pre");

You can also achieve this by changing logsid to be a <pre> element.


Post a Comment for "Newline Is Being Printed As A Whitespace In Text Area Of Html. How Do I Resolve"