Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

selectAllChildren method

Replaces the current selection with all the contents of the given node.

HTML5 A vocabulary and associated APIs for HTML and XHTML, Section 7.6.1Internet Explorer 9

Syntax


HRESULT retVal = object.selectAllChildren(parentNode);

Parameters

parentNode [in]

Type: IDispatch

An IHTMLDOMNode interface that receives the new selection.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Standards information

Remarks

Raises a WrongDocumentError DOMException if the parentNode is in another document. Versions earlier than Internet Explorer 10 will throw the exception as WRONG_DOCUMENT_ERR.

Examples

In this example, your selection is replaced by all the elements of the DIV.


<!DOCTYPE html>
<head>
    <title>Select all children example</title>
    <script type="text/javascript">
        function selectAllChildrenDemo () {
            var getNode = document.getElementById ("elementID");
            if (window.getSelection) {        // Internet Explorer 9
                var selection = window.getSelection ();
                selection.selectAllChildren (getNode);
            } else {                          // Workaround for Internet Explorer 8 & earlier
                var oRange = document.body.createTextRange ();
                oRange.moveToElementText (getNode);
                oRange.select ();
            }
        }
    </script>
</head>
<body>
    <button onclick="selectAllChildrenDemo ();">Select everything below</button>
    <div id="elementID">The <strong>selectAllChildren</strong> method replaces the current <em>selection</em> with the all the <strong>contents</strong> of the specified element (in this case a DIV).</div>
</body>

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.