rwaldron / idiomatic.js

Principles of Writing Consistent, Idiomatic JavaScript
Other
24.66k stars 3.46k forks source link

replaced #foo with .foo #274

Open ahelmi365 opened 1 year ago

ahelmi365 commented 1 year ago

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".