JSFiddle - React, Tailwind, and code Playground
HTML
<br />
<div id='container'>
<div id='commentBox' contentEditable>
line 1<br/> line2<br/><br/>line4\nline5
</div>
<button id='saveButton'>SAVE</button>
</div>
CSS
div#container {
margin: 0 auto;
width: 80%;
}
div#commentBox {
border: 1px solid #eee;
padding: 4px;
}
JavaScript
var Comments = 'div#commentBox';
var saveButton = 'button#saveButton';
$(saveButton).click(function() {
var commentsBox = $(Comments);
var updatedHTML = commentsBox.html();
var updatedText = commentsBox.text();
var nativeUpdatedText = $(Comments)[0].innerText;
alert(nativeUpdatedText);
alert(updatedText)
/*$.ajax {
// POST request here...
}*/
});