These are chat archives for bem/talk

Sep 2014
Jitendra Vyas
Sep 18 2014 14:35 UTC

Hello people who uses BEM, How do you select HTML element in Javascript?

a) prefixed classes specifically for js like .js-something
b) by #id which will not be use for styling
c) or data-* attributes?

Vladimir Grinenko
Sep 18 2014 17:27 UTC
hi, @jitendravyas!
we use a) but js- part is unnecessary — you can use just the same classes as you use for styling. BEM blocks encapsulate everything about themselves: styling, behavior (JS), images, tests, documentation, etc. so when there’s for example button block, it’ll have button.css, button.js, button.png, button.spec.js and describing all the aspects of the button. all of them will mutch same .button class in HTML.