Using the WinJS.Utilities.children() method

The WinJS.Utilities.children() method enables you to retrieve a QueryCollection which contains all of the children of a DOM element. For example, imagine that you have a DIV element which contains children DIV elements like this:

<div id="discussContainer">   <div>Message 1</div>   <div>Message 2</div>   <div>Message 3</div></div>

You can use the following code to add borders around all of the child DIV elements and not the container DIV element (see Figure 2.8):

var discussContainer = WinJS.Utilities.id("discussContainer").get(0);WinJS.Utilities.children(discussContainer).setStyle("border", "2px dashed red");

FIGURE 2.8 Retrieving children ...

Get Windows® 8.1 Apps with HTML5 and JavaScript Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.