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: enter image description here

:( don't understand. why length 0? works in fiddle: http://jsfiddle.net/p7yfv37s/

i printed object again after length, , still shows length: 4. enter image description here

if put cursor on i icon see htmlcollection state captured upon first expansion. not show state @ moment of console.log invocation.

enter image description here

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

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -