Your Search Results

    collapse Redirect 1

    « DOM Reference

    Summary

    Collapses the current selection to a single point. The document is not modified. If the content is focused and editable, the caret will blink there.

    Syntax

    sel.collapse(parentNode, offset);
    

    Parameters

    parentNode
    The caret location will be within this node.
    offset
    0 - Collapses the selection from the anchor to the beginning of parentNode's text.
    1 - Collapses the selection from the anchor to the end of parentNode's text.

    Examples

    /* Place the caret at the beginning of an HTML document's body. */
    var body = document.getElementsByTagName("body")[0];
    window.getSelection().collapse(body,0);
    

    Document Tags and Contributors

    Contributors to this page: Sheppy
    Last updated by: Sheppy,