3 ms·
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
by foresterh 15y ago
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.
- Javve 15y agoThe 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())
- catshirt 15y agoi 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()