Insert HTML

This example shows how to use API for inserting HTML at the caret.

API Commands

Code

<!-- buttons -->
<button onclick="insertContent(event)">insertContent</button>

<!-- element -->
<textarea id="entry">...</textarea>

<!-- call -->
<script>
let app = Redactor('#entry');

function insertContent(e) {
    e.preventDefault();
    e.stopPropagation();

    app.editor.insertContent({ html: '<p>Here is it! I am inserted.</p>', caret: 'end' });
}
</script>