Since it is not recommended to use the same ID for multiple HTML elements on the same page, and since the purpose of an ID attribute is to uniquely identify a single element within an HTML document. Using the same ID for multiple elements would violate this principle and can lead to various issues. So considering this rule, the query() function will return one element with the give id #foo, which means that the for loop will iterate once. So I've changes the selector to be .foo (class selector) so we may get more than one element with the same class name "foo".
Since it is not recommended to use the same ID for multiple HTML elements on the same page, and since the purpose of an ID attribute is to uniquely identify a single element within an HTML document. Using the same ID for multiple elements would violate this principle and can lead to various issues. So considering this rule, the
query()
function will return one element with the give id#foo
, which means that thefor
loop will iterate once. So I've changes the selector to be.foo
(class selector) so we may get more than one element with the same class name "foo".