0
Why is there an 's' in getElementsByTagName & in..... ByClassName and none in ... ById
4 ответов
+ 4
the primary reason why there is "s" within the command is because the "getElementsByTagName" returns an array of the tag(s). for example within a list you might have many list items and in that case, the "getElementsByTagName" will return an array with all those tags.
+ 1
This is becouse there are many elements in document and there are many elements with the same class.
Sow if you do this:
var arr = document.getElementsByTagName("p") // you have an array with all "p" elements of your page.
https://www.w3schools.com/tags/att_id.asp
The id attribute specifies a unique id for an HTML element (the value must be unique within the HTML document).
+ 1
because the ID is unique on the DOM, but u can have different element with same class not the same ID
0
supporting for 2 comments above
getElementsByName with a "s" because you can put name to anchor for many time
but getElementById means that you just can put 1 id and just 1