Number of items per page

While I was playing with Prototypejs JavaScript library, I found that

$$("*").length < document.getElementsByTagName("*").length

I wonder why prototypejs always gives a smaller number.


EDIT

After Dr. Molle Answer, I tried on another page, where I found the difference in length 3 is not always 1. Then I found that

and. which starts with "!" after angle brackets (total 1)

b. <! - → comment (there were 2 comments on the page) (total 2)

Interesting: "!" also appears as tagName along with another tag, for example. div, span, script, etc.

The following code is used in the IE Developer Tool

var allEles=document.getElementsByTagName("*");
$A(allEles).each(function(el){
console.log(el.tagName);
});

shows ..

LOG: !

LOG: HTML

LOG: HEAD
+3
source share
1 answer

, MSIE ( , ) getElementsByTagName() <!DOCTYPE>, $$() .

DOCTYPE IE getElementsByTagName('*') tagName ! nodeType 8

nodeType, , DOCTYPE - node ( nodeType 8), , MSIE getElementsByTagName()

+3

Source: https://habr.com/ru/post/1783973/


All Articles