Jquery textarea val () does not accept newline

I get a text box with a keyup function attached. When the user enters something, I want this text to appear inside the blockquote tag. It works, but id does not accept newlines and spaces. Could you help me?

$('#post_body').keyup(function() {    
$('blockquote').find('span').text($(this).val());
+3
source share
2 answers

A new line is required, however when rendering HTML they are usually ignored. However, you can give that <span>(or <blockquote>) the rendering of the line to match by setting it white-sapceto the same as a <pre>, for example:

blockquote span { white-space: pre; }​
//or..
blockquote { white-space: pre; }​

You can check it out here .

+6
source

<br/>; &amp;nbsp;

0

Source: https://habr.com/ru/post/1769864/


All Articles