editor.getEditable(bFocus)
Returns the editable root element — the body inside the editor’s iframe that actually holds the content the user types into. Reach for it when you need the container element itself: to read its children, measure it, or scope a query to just the edited content.
Syntax
editor.getEditable(bFocus)
Parameters
bFocus — optional boolean. When true, the editor is focused before the element is returned. Omit it (or pass a falsy value) to get the element without changing focus.
Returns
The editable body element.
Behavior notes
- Element, not document. This returns the body element; getDocument() returns the surrounding
Document. Both live inside the editing iframe. - Optional focus is a convenience. Passing
truesaves a separate focus() call when you are about to place a selection or start editing. - Query against it to stay scoped. A
querySelectoron the returned element only ever sees the edited content, never the surrounding page chrome.
Example usage
Read the first paragraph of the edited content:
var editor1 = new RichTextEditor("#div_editor1");
var body = editor1.getEditable();
var firstPara = body.querySelector("p");Focus the editor and get the editable in one call before setting a selection:
var body = editor1.getEditable(true); // focuses, then returns the elementRelated
- editor.getDocument()— the Document that contains this element.
- editor.focus()— move keyboard focus into the editor.
- editor.getHTMLCode()— get the content as an HTML string instead of a live element.