共用方式為


WinJS.Utilities.children function

Gets a collection of elements that are the direct children of the specified element.

Syntax

var queryCollection = WinJS.Utilities.children(element);

Parameters

  • element
    Type: DOMElement

    The parent element

Return value

Type: QueryCollection**

The collection of children of the element.

Examples

The following code shows how to use this function.

<div id="ratingDiv" data-win-control="WinJS.UI.Rating"></div>
<script type="text/javascript">
     WinJS.UI.processAll();
     var div = document.getElementById("ratingDiv");

     var children = WinJS.Utilities.children(div);

     var i = 0;
     while (i < children.length) {
         var child = children[i++];
         if (WinJS.Utilities.hasClass(child, "win-star")) {
             var rating = WinJS.Utilities.data(child);
             var y = rating.msStarRating;
         }
     }
</script>

Requirements

Minimum WinJS version

WinJS 1.0

Namespace

WinJS.Utilities