Create editor instances by replacing <textarea> or <div> elements with textboxio.replace(). The initial content of the editor is set to the content/value of the replaced element.

When Textbox.io replaces a <textarea> element within a <form>, it will update the original <textarea> element when the form is submitted, supplying updated content as part of the <form> POST. 

When Textbox.io replaces <div> elements, content must be requested from Textbox.io using a JavaScript API, see: Setting and Getting Content.

Example

textboxio.replace(selector, [configuration])
<div id="replaceMe">Content</div>
...
// Create a Textbox.io editor by searching for a DOM element with id 'replaceMe'
var simpleEditor = textboxio.replace( '#replaceMe' );
textboxio.replace(element, [configuration])
<div id="replaceMe">Content</div>
...
// Create a Textbox.io editor by replacing a specific DOM element
var div = document.getElementById('replaceMe');
var simpleEditor = textboxio.replace( div );

Parameters

selector

or

element

String

or

Element

Specify a CSS3 selector representing the <div> or <textarea> element you wish Textbox.io to replace for editing.

or

The <div> or <textarea> element you wish Textbox.io to replace for editing.

configuration Object (optional)

An optional group of key-value pairs that specify options/settings for the Textbox.io instances you are invoking.

Note about selectors

If the selector matches multiple elements, only the first is replaced as per the rules for querySelector.

If it does not match any elements, a JavaScript error will be thrown. If the number of elements that will match is not known, use replaceAll which does not have this restriction.

Returns

textboxio.editorObject

A single instance of the Textbox.io editor.