JavaScript Selection and Range

# basics
`window.getSelection` and `document.getSelection` all returns the `Selection` object, the selection object is almost useless.

`window.getSelection.getRangeAt(0)` returns a Range object. for history reasons, there is only one range in each selection.

`rangeAncestor = range.commonAncestorContainer;` commonAncestorContainer is the common ancestor of the range elements.

About 逸飞

后端工程师

发表评论

电子邮件地址不会被公开。 必填项已用*标注