-
Notifications
You must be signed in to change notification settings - Fork 0
jQuery.fn.getBlock()
- jQuery.fn.getBlock(blockName)
- jQuery.fn.getBlock(blockName, modifier)
- jQuery.fn.getBlock(blockName, modifierName, modifierValue)
Version added: 1.0.0
Returns a list of matched blocks, containing in the current set of jQuery objects.
A list of matched blocks if there are any; otherwise - an empty list.
Type: jQuery object
blockName
The name of the block.
Type: String
Gets blocks by the name of the block:
HTML:
<html>
<body>
<div id="product1" class="product"></div>
<div class="products">
<div id="product2" class="product"></div>
<div id="product3" class="product"></div>
<div class="offer"></div>
</div>
<div class="products">
<div id="product4" class="product"></div>
</div>
<div id="product5" class="product"></div>
</body>
</html>
Code:
var $blocks = $('.products').getBlock('product');
Result:
The $blocks variable will contain three blocks with identifiers product2, product3 and product4.
Version added: 1.0.0
Returns a list of matched blocks, containing in the current set of jQuery objects.
A list of matched blocks if there are any; otherwise - an empty list.
Type: jQuery object
blockName
The name of the block.
Type: String
modifier
One or more modifiers, separated by a space.
Type: String
Gets blocks by the name of the block and the modifier:
HTML:
<html>
<body>
<div id="product1" class="product"></div>
<div class="products">
<div id="product2" class="product"></div>
<div id="product3" class="product product_is-selected"></div>
<div class="offer"></div>
</div>
<div class="products">
<div id="product4" class="product product_is-selected"></div>
</div>
<div id="product5" class="product product_is-selected"></div>
</body>
</html>
Code:
var $blocks = $('.products').getBlock('product', 'is-selected');
Result:
The $blocks variable will contain two blocks with identifiers product3 and product4.
Gets blocks by the name of the block and a string of modifiers:
HTML:
<html>
<body>
<div id="product1" class="product"></div>
<div class="products">
<div id="product2" class="product"></div>
<div id="product3" class="product product_is-selected product_size_xs"></div>
<div class="offer"></div>
</div>
<div class="products">
<div id="product4" class="product product_is-selected"></div>
<div id="product5" class="product product_is-selected product_size_xs product_is-focused"></div>
</div>
<div id="product6" class="product product_is-selected product_size_xs"></div>
</body>
</html>
Code:
var $blocks = $('.products').getBlock('product', 'is-selected size_xs');
Result:
The $blocks variable will contain two blocks with identifiers product3 and product5.
Version added: 1.0.0
Returns a list of matched blocks, containing in the current set of jQuery objects.
A list of matched blocks if there are any; otherwise - an empty list.
Type: jQuery object
blockName
The name of the block.
Type: String
modifierName
The name of the modifier.
Type: String
modifierValue
The value of the modifier.
Type: String
Gets blocks by the name of the block, the name of the modifier and the value of the modifier:
HTML:
<html>
<body>
<div id="product1" class="product"></div>
<div class="products">
<div id="product2" class="product"></div>
<div id="product3" class="product product_size_xs"></div>
<div id="product4" class="product product_size"></div>
<div class="offer"></div>
</div>
<div class="products">
<div id="product5" class="product product_size_xs"></div>
</div>
<div id="product6" class="product product_size_xs"></div>
</body>
</html>
Code:
var $blocks = $('.products').getBlock('product', 'size', 'xs');
Result:
The $blocks variable will contain two blocks with identifiers product3 and product5
bem.elementSeparator
bem.modifierSeparator
bem.modifierValueSeparator
bem.block()
bem.blockModifier()
bem.element()
bem.elementModifier()
bem.getBlock()
bem.getElement()
jQuery.fn.addModifier()
jQuery.fn.blockName()
jQuery.fn.elementName()
jQuery.fn.getBlock()
jQuery.fn.getElement()
jQuery.fn.hasModifier()
jQuery.fn.isBlock()
jQuery.fn.isElement()
jQuery.fn.modifierValue()
jQuery.fn.removeModifier()