This example shows how to use API for getting and setting the HTML content.
<!-- buttons -->
<button onclick="getContent(event)">getContent</button>
<button onclick="setContent(event)">setContent</button>
<!-- element -->
<textarea id="entry">...</textarea>
<!-- call -->
<script>
let app = Redactor('#entry');
function setContent(e) {
e.preventDefault();
e.stopPropagation();
app.editor.setContent({ html: '<p>Here is it! I am set.</p>', caret: 'end' });
}
function getContent(e) {
e.preventDefault();
let html = app.editor.getContent();
console.log(html);
}
</script>