As Amani said, you should use some external library, e.g. CKEditor or TineMCE. Then, bind on change event to replace the content of destination element.
HTML:
<textarea name="editor"></textarea>
<div id="result">
<p>Put some text in the editor to see the preview.</p>
</div>
JS:
var editor = CKEDITOR.replace('editor', {
height: 100
});
editor.on('change', function () {
$('#result').html(this.getData())
});
solved Creating a text editor through jquery [closed]