domyuiyui3

YUI3 Get children of a element


I'm trying to get all children of a YUI3 Element like this

Y.one(document.body).children 
// results in undefined

But I see a children attribute here: https://clarle.github.io/yui3/yui/docs/api/classes/Node.html#attr_children


Solution

  • To get YUI attributes, you need to call the #get method for that attribute:

    Y.one(document.body).get('children');
    

    Runnable example:

    YUI().use('node', function(Y) {
      console.log(Y.one(document.body).get('children'));
    });
    <script src="https://cdn.rawgit.com/stiemannkj1/0214fdc4cccaa77d6e504320cf70a571/raw/63d260364730fb067f103c00862c7e65685256df/yui-3.18.1_build_yui_yui-min.js"></script>
    <div id="wrapper" class="yui3-skin-sam">
    </div>