jQuery.BEM
jQuery.BEM is small jQuery plugin for comfortable working with HTML made by BEM method.
- Learn more about BEM: http://bem.info/
Selecting elements
Coffe $2 Tea $1
; // $('.b-product:first > .b-product__name'); // $('.b-product:first > .b-product__name').closest('.b-product'); // $('.b-product:first > .b-product__name').siblings('.b-product__price')
Working with modifiers
Setting modifier
...
; // will get .b-product.b-product_theme_premium; // will get .b-product.b-product_premium_true
Remove modifier
...
; // $('.b-product').removeClass('.b-product_theme_premium');; // remove the modifier "theme" of any value (.b-product_theme_*); // same
Getting modifier
...
// will return "premium"; // will rerurn null (non-existent modifier)
Checking modifier
...
; // true; // true // false
Filtering by modifier
......
; // instead of $('.b-product.b-product_theme_premium'); // instead of $('.b-product').not('.b-product_theme_premium'); // filtering by modifier "theme" of any value (?)