Get and set code

This example shows how to use API for getting and setting the HTML code.


Code

<!-- api buttons -->
<button onclick="getCode();">Get</button>
<button onclick="setCode();">Set</button>

<!-- element -->
<textarea id="content"></textarea>

<!-- call -->
<script>
var app = RedactorX('#entry');

function setCode() {
    app.editor.setContent({ html: '<p>Here is it! I am set.</p>' });
}

function getCode() {
    var html = app.editor.getContent()
    console.log(html);
}
</script>