Insert HTML

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

    Demo


    Code

    <!-- api button -->
    <button onclick="insertHtml(event);">Insert HTML</button>
    
    <!-- element -->
    <textarea id="entry"></textarea>
    
    <!-- call -->
    <script>
    var app = RedactorX('#entry');
    
    function insertHtml(e) {
        e.preventDefault();
        e.stopPropagation();
        app.editor.insertContent({ html: '<p>Hello world</p>' });
    }
    </script>