[Reference] Events
document.addEventListener('selectionchange', () => {})
[Reference] Deleting
sel.deleteFromDocument()
[Reference] Collapsing
sel.collapse(parent, offset)
sel.collapseToEnd()
sel.collapseToStart()
sel.isCollapsed
sel.containsNode(node)
[Reference] Methods
sel.removeAllRanges() // deselects
sel.addRange(range) // sets a selection
sel.removeRange(range) // remove a range
sel.rangeCount
sel.getRangeAt(0) // get the 0th range
[Reference] Selection
var sel = document.getSelection()
See: https://devdocs.io/dom/selection
Reference
{: .-three-column}
Top comments (0)