I have this piece of code:
var size = iframe.contentWindow.document.getElementsByClassName('checked').getElementsByTagName('span')[0].innerHTML;
For some reason every time I run it I get this message:
Uncaught TypeError: Object [object NodeList] has no method ‘getElementsByTagName’
Even though all my other functions with getElementsByTagName() work fine. What could be the reason for this error?
Thanks
getElementsByClassNamereturns a set of elements (i.e.NodeList), not a single element:Besides you can replace it with
querySelector: