Range.cloneRange()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2017.
**Range.cloneRange()
**方法返回一个 range 对象,并且该对象的范围边界点与被克隆的 range 对象相同。
克隆的对象是复制过来的,而非引用,所以这两个对象双方各自做出的改变,都不会影响另一方。
语法
clone = range.cloneRange();
Example
js
range = document.createRange();
range.selectNode(document.getElementsByTagName("div").item(0));
clone = range.cloneRange();
Specifications
Specification |
---|
DOM Standard # dom-range-clonerange |
Browser compatibility
BCD tables only load in the browser