addRange

Table of contents

  1. 1. Summary
  2. 2. Syntax
  3. 3. Parameters
  4. 4. Examples
Table of contents
  1. 1. Summary
  2. 2. Syntax
  3. 3. Parameters
  4. 4. Examples

« Gecko DOM Reference

Summary

Adds a Range  to a Selection .

Syntax

sel.addRange(range)

Parameters

range
A Selection object that will be added to the Selection .

Examples

 /* Select all STRONG elements in an HTML document */
 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);
 }

Tags (3)

Edit tags

Attachments (0)

 

Attach file