JSFiddle - React, Tailwind, and code Playground
HTML
<div id="board_code" contenteditable = "true"></div>
<input type="button" id="save" value="save"/>
CSS
#board_code{
white-space: pre;
background-color: green;
}
JavaScript
$('#save').click(function(e) {
var id = "board_code";
var ce = $("<pre />").html($("#" + id).html());
if ($.browser.webkit)
ce.find("div").replaceWith(function() { return "\n" + this.innerHTML; });
if ($.browser.msie)
ce.find("p").replaceWith(function() { return this.innerHTML + "<br>"; });
if ($.browser.mozilla || $.browser.opera || $.browser.msie)
ce.find("br").replaceWith("\n");
alert( ce.text() );
});