getHTMLElement
Release 2.11.0+
Returns the HTML element at the given position. If position is omitted, returns the HTML element at the current caret position.
Parameters
| Name | Type | Description |
|---|---|---|
[position] | Position | (Optional) Position from a Selection. If omitted, the current caret position is used. |
Returns
| Type | Description |
|---|---|
| HTMLElement | The element at the position |
Example
// Without explicit position
var element = editor.getHTMLElement();
console.log(element.innerHTML);
// With positions from a Selection
var selection = editor.getSelection();
var startElement = editor.getHTMLElement(selection.start);
console.log(startElement.innerHTML);
var endElement = editor.getHTMLElement(selection.end);
console.log(endElement.innerHTML);