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

NameTypeDescription
[position]Position(Optional) Position from a Selection. If omitted, the current caret position is used.

Returns

TypeDescription
HTMLElementThe 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);