Document.createRange()
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
物件。
語法
range = document.createRange();
創造 range
為 Range
物件.
示例
js
var range = document.createRange();
range.setStart(startNode, startOffset);
range.setEnd(endNode, endOffset);
註意
當 Range
被創建之後,必須先設定其範圍初始點及結束點, 才能使用大部分 Range
所提供的方法。