Hacker News new | past | comments | ask | show | jobs | submit login

Use ids when JS needs to reference unique elements. Use classes for styling and accessing groups.



JS can do just as well with unique classnames, which avoids issues with ids like those given in the article.


I always presumed this would usually entail a performance hit, since you are accessing something that is not defined as unique.


It's an infinitesimal performance decrease, and it avoids a lot of other issues.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: