这篇翻译不完整。请帮忙从英语翻译这篇文章。
概述
语法
sel.addRange(range)
参数
例子
/* 在一个HTML文档中选中所有加粗的文本。 */ var strongs = document.getElementsByTagName("strong"); var s = window.getSelection(); if(s.rangeCount > 0) s.removeAllRanges(); for(var i = 0; i < strongs.length; i++) { var range = document.createRange(); range.selectNode(strongs[i]); s.addRange(range); }
Specifications
Specification | Status | Comment |
---|---|---|
HTML Editing APIs Selection.addRange() |
Editor's Draft | Initial definition |
Selection API Selection.addRange() |
Working Draft | Current |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | ? | (Yes) | ? | ? | ? |
Feature | Android | Firefox Mobile (Gecko) | Firefox OS | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | ? | (Yes) | 1.0 | ? | ? | ? |
See also
Selection
, the interface it belongs to.