Alexis Alexis - 1 year ago 71
jQuery Question

Creating a text editor through jquery

Well... Explanation is simple I want to create a text editor just like stackoverflow where you type and beneath the text is formatted and shown.

Lets keep the thing simple

This is a simple thing I tried.

`https://jsfiddle.net/dh4qpzzv/`


But it doesn't push the text to the span.

Answer Source

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.

JSFiddle: https://jsfiddle.net/gf4v9b8x/

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())
});
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download