--- title: Selection.collapseToEnd() slug: Web/API/Selection/collapseToEnd translation_of: Web/API/Selection/collapseToEnd ---
{{ ApiRef("DOM") }}{{SeeCompatTable}}

Selection.collapseToEnd() 方法的作用是取消当前选区,并把光标定位在原选区的最末尾处,如果此时光标所处的位置是可编辑的,且它获得了焦点,则光标会在原地闪烁。

语法

sel.collapseToEnd()

参数

规范

Specification Status Comment
{{SpecName('HTML Editing', '#dom-selection-collapsetoend', 'Selection.collapseToEnd()')}} {{Spec2('HTML Editing')}} Initial definition
{{SpecName('Selection API', '#widl-Selection-collapseToEnd-void', 'Selection.collapseToEnd()')}} {{Spec2('Selection API')}} Current

浏览器兼容性

{{Compat("api.Selection.collapseToEnd")}}

相关链接