Visit Mozilla.org

DOM:range.collapse

From MDC

« Gecko DOM Reference

Contents

[edit] Summary

Collapses the Range to one of its boundary points.

[edit] Syntax

range.collapse(toStart);

[edit] Parameters

toStart 
A boolean, true collapses the Range to its start, false to its end.

[edit] Example

range = document.createRange();
referenceNode = document.getElementsByTagName("div").item(0);
range.selectNode(referenceNode);
range.collapse(true);

[edit] Notes

A collapsed Range is empty, containing no content, specifying a single-point in a DOM tree. To determine if a Range is already collapsed, see the collapsed property.

[edit] Specification

collapse