We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

这篇翻译不完整。请帮忙从英语翻译这篇文章

 Range.collapsed 是只读属性。它返回一个 Boolean 值表示是否起始点和结束点是同一个位置。 如果返回 true 表示Range 的起始位置和结束位置重合, false 表示不重合。

 一个折叠的Range 是空的,不包含内容,表示Dom树中的一个点。collapsed 属性是只读的。可以调用 Range.collapse() 方法来折叠选区。

语法

isCollapsed = range.collapsed;

例子

var range = document.createRange(); 

range.setStart(startNode,startOffset); 
range.setEnd(endNode,endOffset);
isCollapsed = range.collapsed;

规范

Specification Status Comment
DOM
Range.collapsed
Living Standard No change.
Document Object Model (DOM) Level 2 Traversal and Range Specification
Range.collapsed
Obsolete Initial specification.

浏览器兼容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) 1.0 (1.7 or earlier) 9.0 9.0 (Yes)
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) 1.0 (1.0) 9.0 9.0 (Yes)

参阅

文档标签和贡献者

此页面的贡献者: GentleMint, Smart
最后编辑者: GentleMint,