I have text that comes from a textarea where the user might have legitimate carriage returns.
If the text has a carriage return that I want to preserve, how do I do that with this exact jQuery append example.
I'm generating this html code and it will break if the variable $text has carriage returns in it.
Example:
$(".inner").append( "<textarea><?php echo $text; ?></textarea>" );
So if:
$text = "Cat
Dog";
Then I get this and it causes an error.
$( ".inner" ).append( "<textarea>Cat
Dog</textarea>" );
What can I do to preserve the carriage returns when append creates this textarea html?
, although that might mangle formatting. – Michael McPherson Aug 04 '15 at 19:51
` in a textarea, you need a `\n` to get a new line there. – jeroen Aug 04 '15 at 19:53