I often use CSS ids or classes to select elements in Javascript. Many of those classes do just exist for that use case and do not have any styles attached at all.
I ponder now if it would be any good to mark those classes explicitly. Maybe something like a leading underscore (e.g. class="_field").
The thing is that I never heard of such a practice. Is this recommended? Maybe already used in a bigger project? What kind of marking would make sense? I read somewhere that a leading underscore could be problematic. What else could I use to easily identify those “Javascript only” classes?
You can do that as a personal coding convention. The spec doesn’t state that the
classattribute must be used in styling only, or in scripting only. You can use it to classify your elements in any way you want, so there’s no restriction in how you name and organize your classes.