|
|
|
|
|
by err4nt
2826 days ago
|
|
How come people who do this only ever use class names? Why not invent your own data attribute like data-hover="red" where you create new namespaces for things like hover, or pseudo classes, why it it always only ever class names? |
|
The classList API makes modifications to the class property very easily.
You'd be essentially limited to one identifier in attribute selectors. You can't really select from multiple identifiers with a data attribute without doing like:
which would search for "foo" anywhere in the attribute, which could mean incorrect substring matches.Chaining attribute selectors would be rough too:
vs