3 ms·
You shouldn't be using IDs anyways. They are just bad for a lot of reasons. You can only have one on a page and it reduces your reusability. Use classes instead
by bhhaskin 4y ago
You shouldn't be using IDs anyways. They are just bad for a lot of reasons. You can only have one on a page and it reduces your reusability. Use classes instead.
- err4nt 4y agoID's aren't bad, they're unique identifiers, and useful for (deep) linking to specific pieces of content within documents. Please use ID's as liberally as you please, and use them for their proper use.
- goatlover 4y agoUse ids when JS needs to reference unique elements. Use classes for styling and accessing groups.
- isleyaardvark 4y agoJS can do just as well with unique classnames, which avoids issues with ids like those given in the article.
- sgc 4y agoI always presumed this would usually entail a performance hit, since you are accessing something that is not defined as unique.
- isleyaardvark 4y agoIt's an infinitesimal performance decrease, and it avoids a lot of other issues.