Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This looks pretty useful. I'm curious why you used class to store the "category". Wouldn't it be cleaner to store it in"data-category" or just Javascript? Or is that less browser compliant?

Overall a great script though.



The reason is simply that I wanted it to be as simple as possible, but if it seems to be a common request I could add support for data-attributes! (and yes, it "works" in IE, by using getAttribute())


i used to use class names to store data types (category is a perfect example). there's a really great reason to do this: you can style your objects based on that type of data without relying on CSS attribute selectors.

that said, i quickly learned that it's better to use data- attributes and copy them into the class when necessary. otherwise you end up with utilities like getCategoryFromClassName()




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

Search: