insertHTML()
This example shows how to use editor.insertHTML(html) to place HTML into the editor. If content is selected, the selection is replaced by the inserted markup.
Example code
<link rel="stylesheet" href="/richtexteditor/rte_theme_default.css" />
<script type="text/javascript" src="/richtexteditor/rte.js"></script>
<script type="text/javascript" src='/richtexteditor/plugins/all_plugins.js'></script>
<div id="div_editor1"></div>
<script>
var editor1 = new RichTextEditor("#div_editor1");
editor1.setHTMLCode("<p>Hello World</p>");
function btnInsertHTMLCode_1() {
editor1.insertHTML("Time is" + new Date().toLocaleTimeString())
editor1.collapse(false);
editor1.focus();
}
function btnInsertHTMLCode_2() {
editor1.selectDoc(false);//collapse to document end
editor1.insertHTML("<p>Insert a new paragraph " + new Date().toLocaleTimeString() + "</p>")
editor1.collapse(false);
editor1.focus();
}
</script>
<div class="content-space-t-1 ">
<button class="btn btn-sm btn-outline-primary btn-pill transition-3d-hover px-5" onclick="btnInsertHTMLCode_1();return false;">Insert HTML at the caret</button>
<button class="btn btn-sm btn-primary btn-pill transition-3d-hover px-5" onclick="btnInsertHTMLCode_2();return false;">Insert HTML at the end of the document</button>
</div>