When I hit 'enter' is added?

Guys, please tell me. Why when you press enter while editing the text, added the contents"<p><br></p>"for a line break?

<div class="textarea" placeholder="Text" contenteditable="true"></div>


$('body').on('click','.wsg ul li',function(){
 var target = $(this).closest('.wsg').find('.textarea'),
 text = target.html()

 target.html(text + '<p>Lorem</p>')
 })
July 8th 19 at 15:55
1 answer
July 8th 19 at 15:57
Use target.val().
with .val() does not work - Salma_Jones commented on July 8th 19 at 16:00
: A possible example of code? That one https://jsfiddle.net/ - Rene.DAmore commented on July 8th 19 at 16:03
: so I brought up code) when .val() nothing is happening at all. And error is also present. - Salma_Jones commented on July 8th 19 at 16:06
: is .val() works for div? like a current input,textarea, and select. - Salma_Jones commented on July 8th 19 at 16:09
: I'm confused, I thought there textare). I did not understand the question. What text and where you you edit in diva?) - Rene.DAmore commented on July 8th 19 at 16:12
: the default text in the div no. I try to write as if your wysiwyg. Read more about the problem read above, because in the comments is not displayed in html - Salma_Jones commented on July 8th 19 at 16:15

Find more questions by tags jQuery