Answer the question
In order to leave comments, you need to log in
BEM (way of naming) do you need classes for JS selectors? And if so, why are they? And what should they look like?
Hello! I'm learning to type in BEM. I've dealt with HTML and CSS. Got to writing JS. And a question arose. Do I need to write any special classes for Javascript selectors? And if so, why are they? And what should they look like? Is it just prefixing "js" to already existing classes? For example js-block__element?
Answer the question
In order to leave comments, you need to log in
If some relatively new framework (vue/react/angular) is used, which itself generates a DOM tree, then special classes will not be needed, because the framework does not need to look for these elements.
If you work the old fashioned way, jquery/backbone.js, then it's more convenient with them. Their point is to separate behavior from presentation, so class="b-block__element js-block__element" is not a good idea, it's better to make classes that describe the role of the element, such as js-placeholder or js-addressInput .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question