What does ByTagName return in the following cases?

-1

which returns getElementByTagName('body') , according to:

  

1) Specifying the index 0
      Bring back ? with all the content and therefore all the tags within body or just the body tag itself?

     

2) Without specifying the index? , the same structure as before.

     

3) In the case of specifying the index [0] and [1] at the same time, it means:

getElementByTagName('body')[0][1] ,

  

what happens?

    
asked by Eduardo Sebastian 24.05.2017 в 04:07
source

1 answer

1

The code getElementByTagName('body') returns an object of type HTMLCollection which you can treat as a Array therefore if you use getElementsByTagName('body')[0] it will return the first element of the collection in the form of html including all the internal html of the body Finally, as getElementsByTagName('body')[0] is not an array if you try to do getElementsByTagName('body')[0][1] you will only get undefined .

    
answered by 24.05.2017 / 04:38
source