--- title: Selection.removeAllRanges() slug: Web/API/Selection/removeAllRanges translation_of: Web/API/Selection/removeAllRanges ---
Selection.removeAllRanges()方法会从当前selection对象中移除所有的range对象,取消所有的选择只 留下{{domxref("Selection.anchorNode", "anchorNode")}} 和{{domxref("Selection.focusNode","focusNode")}}属性并将其设置为null。
sel.removeAllRanges();
无。
| 规范 | 状态 | 注释 |
|---|---|---|
| {{SpecName('HTML Editing', '#dom-selection-removeallranges', 'Selection.removeAllRanges()')}} | {{Spec2('HTML Editing')}} | Initial definition |
| {{SpecName('Selection API', '#widl-Selection-removeAllRanges-void', 'Selection.removeAllRanges()')}} | {{Spec2('Selection API')}} | Current |