Dss
Dss

Reputation: 2360

Javascript: How can I replace newlines from a textarea to a div element?

This jsfiddle explains it all https://jsfiddle.net/qphoria/jh7p0oq2/1/

How do I make the div appear as multiple lines without showing the literal <br> tags?

Upvotes: 1

Views: 29

Answers (3)

user3754008
user3754008

Reputation: 285

use .html() will taking the str as html and render it. .text() will only render str as text.

 $('#display').html(str);

Upvotes: 0

Robiseb
Robiseb

Reputation: 1606

Try using .html() instead

$('#display').html(str);

JSFiddle

Upvotes: 0

John Boker
John Boker

Reputation: 83699

Could probably try

$('#display').html(str);

https://jsfiddle.net/j56vdyfa/1/

Upvotes: 2

Related Questions