-
Notifications
You must be signed in to change notification settings - Fork 0
jQuery.fn.hasModifier()
- jQuery.fn.hasModifier(modifier)
- jQuery.fn.hasModifier(modifierName, modifierValue)
- jQuery.fn.hasModifier(modifiers)
Version added: 1.0.0
Determines whether any of the set of jQuery objects has the modifier(s).
True if any of the set of jQuery objects has the modifier(s); otherwise - false.
Type: Boolean
modifier
One or more modifiers, separated by a space.
Type: String
Determines whether any of the set of blocks has the modifier:
HTML:
<html>
<body>
<div class="product"></div>
<div class="product product_is-selected"></div>
<div class="product"></div>
</body>
</html>
Code:
var hasModifier = $('.product').hasModifier('is-selected');
Result:
true
Determines whether any of the set of elements has the modifier:
HTML:
<html>
<body>
<div class="product__name"></div>
<div class="product__name product__name_is-selected"></div>
<div class="product__name"></div>
</body>
</html>
Code:
var hasModifier = $('.product__name').hasModifier('is-selected');
Result:
true
Determines whether any of the set of blocks has all modifiers from a string of modifiers:
HTML:
<html>
<body>
<div class="product"></div>
<div class="product product_is-selected product_size_xs"></div>
<div class="product"></div>
</body>
</html>
Code:
var hasModifier = $('.product').hasModifier('is-selected size_xs');
Result:
true
Determines whether any of the set of elements has all modifiers from a string of modifiers:
HTML:
<html>
<body>
<div class="product__name"></div>
<div class="product__name product__name_is-selected product__name_size_xs"></div>
<div class="product__name"></div>
</body>
</html>
Code:
var hasModifier = $('.product__name').hasModifier('is-selected size_xs');
Result:
true
Version added: 1.0.0
Determines whether any of the set of jQuery objects has the modifier.
True if any of the set of jQuery objects has the modifier; otherwise - false.
Type: Boolean
modifierName
The name of the modifier.
Type: String
modifierValue
The value of the modifier.
Type: String
Determines whether any of the set of blocks has the modifier with name and value:
HTML:
<html>
<body>
<div class="product"></div>
<div class="product product_size_xs"></div>
<div class="product"></div>
</body>
</html>
Code:
var hasModifier = $('.product').hasModifier('size', 'xs');
Result:
true
Determines whether any of the set of elements has the modifier with name and value:
HTML:
<html>
<body>
<div class="product__name"></div>
<div class="product__name product__name_size_xs"></div>
<div class="product__name"></div>
</body>
</html>
Code:
var hasModifier = $('.product__name').hasModifier('size', 'xs');
Result:
true
Version added: 1.0.0
Determines whether any of the set of jQuery objects has the modifier(s).
True if any of the set of jQuery objects has the modifier(s); otherwise - false.
Type: Boolean
modifiers
A list of modifiers.
Type: Array
Determines whether any of the set of blocks has all modifiers from a list of modifiers:
HTML:
<html>
<body>
<div class="product"></div>
<div class="product product_is-selected product_size_xs"></div>
<div class="product"></div>
</body>
</html>
Code:
var hasModifier = $('.product').hasModifier(
[{ name: 'is-selected' }, { name: 'size', value: 'xs' }]
);
Result:
true
Determines whether any of the set of elements has all modifiers from a list of modifiers:
HTML:
<html>
<body>
<div class="product__name"></div>
<div class="product__name product__name_is-selected product__name_size_xs"></div>
<div class="product__name"></div>
</body>
</html>
Code:
var hasModifier = $('.product__name').hasModifier(
[{ name: 'is-selected' }, { name: 'size', value: 'xs' }]
);
Result:
true
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()