How can I add a <br/>
to <p contenteditable>
when the user press the Enter key in jQuery or javascript?
I tried every solution with no happy ending. A div
element is always showing.
Currently trying on Chrome browser.
This is the solution for now:
$(this).val($(this).val() + "\n");
setTimeout(function(){
$($editedDiv).html($('.ui-selected').html().replace(/<div>(.*?)<\/div>/, "<br>$1"));
},100);
The problem with this solution is that tha caret location is moving to the start of the sentence when i press Enter