javascript - HTMLCollection Length does not match logged object -
// find posts var posts = node.getelementsbyclassname("usercontentwrapper"); var post, text; console.log(posts); console.log(typeof(posts)); console.log(object.keys(posts)); console.log(posts.length); the above outputs: 
:( don't understand. why length 0? works in fiddle: http://jsfiddle.net/p7yfv37s/
i printed object again after length, , still shows length: 4. 
if put cursor on i icon see htmlcollection state captured upon first expansion. not show state @ moment of console.log invocation.

most logging performed before dom loaded or node dynamically populated javascript. htmlcollection kind of live collection track dom changes (more info difference between htmlcollection , nodelist)
see simple example: http://jsfiddle.net/p7yfv37s/1/
Comments
Post a Comment