Problem with line break JS

1

The problem is this, when breaking the line in textarea in div .result where it is supposed to appear the result of what is typed in textarea , it only gives a space and does not break the line.

How do I break the line when one jumps the same in textarea
Here is my code below:

$('.text').keyup(function(e) {
	$('span.result').html( $('.text').val() );
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><textareaname="" class='text' placeholder='texto'></textarea>
<br/>
<span class='result'>texto</span>
    
asked by anonymous 06.08.2016 / 06:03

1 answer

1

In order for the line to break it is necessary to use the word-wrap: break-word; property in your CSS code as follows:

.result {
    word-wrap: break-word;
}
  

More information about this property at: CSS3 word-wrap Property

    
06.08.2016 / 06:15