RichTextEditor Demo
Home Pricing

## Setting and Getting HTML content

This article outlines common methods for working with HTML content using RichTextEditor.

## 1. Getting Content with Javascript

1. <!-- Create a new DIV element with all of the content that we want inside the Editor -->
2. <div id="div_editor1"></div>

1. //Initialize Richtexteditor for the matched element
2. var editor1 = new RichTextEditor("#div_editor1");
3. //Setting Content with Javascript
4. editor1.setHTMLCode("Use inline HTML or setHTMLCode to set the default content.");

1. <!-- Retrieve the HTML from the editor by using the editor.getHTMLCode() method. -->
2. <button onclick="alert(editor1.getHTMLCode())">Show Html Code</button>

## 2. Getting Content Automatically with HTML <form> POST

When RichTextEditor is used to replace a <textarea> element within a <form>, RichTextEditor will mimic the behavior of the original <textarea> when the form is submitted. This means that the contents of the editor are simply posted along with the other form elements, using the name attribute of the original <textarea> as the key.

1. <!-- Create a new DIV element with all of the content that we want inside the Editor -->
2. <textarea id="inp_editor1">&lt;p&gt;Initial Document Content&lt;/p&gt;</textarea>

1. //Initialize Richtexteditor for the matched element
2. var editor1 = new RichTextEditor("#inp_editor1");

The document content will auto sync to textarea when user changed it .