Skip to content

jQuery.fn.removeModifier()

Evgenii Koriakin edited this page Oct 14, 2015 · 4 revisions

Overloads

jQuery.fn.removeModifier(modifier)

Version added: 1.0.0

Summary

Removes the modifier(s) from each block or element of the current set of jQuery objects. This method retains chaining.

Returns

The current set of jQuery objects.

Type: jQuery object

Parameters

modifier

One or more modifiers, separated by a space.

Type: String

Examples

Removes modifiers defined as a string from a set of blocks:

HTML:

<html>
<body>
    <div class="product product_is-selected product_size_xs clearfix"></div>
    <div class="product product_is-selected product_size_xs"></div>
</body>
</html>

Code:

$('.product').removeModifier('is-selected size_xs');

Result:

<html>
<body>
    <div class="product clearfix"></div>
    <div class="product"></div>
</body>
</html>

Removes modifiers defined as a string from a set of elements:

HTML:

<html>
<body>
    <div class="product__name product__name_is-selected product__name_size_xs clearfix"></div>
    <div class="product__name product__name_is-selected product__name_size_xs"></div>
</body>
</html>

Code:

$('.product__name').removeModifier('is-selected size_xs');

Result:

<html>
<body>
    <div class="product__name clearfix"></div>
    <div class="product__name"></div>
</body>
</html>

jQuery.fn.removeModifier(modifierName, modifierValue)

Version added: 1.0.0

Summary

Removes the modifier from each block or element of the current set of jQuery objects. This method retains chaining.

Returns

The current set of jQuery objects.

Type: jQuery object

Parameters

modifierName

The name of the modifier.

Type: String

modifierValue

The value of the modifier.

Type: String

Examples

Removes the modifier with name and value from a set of blocks:

HTML:

<html>
<body>
    <div class="product product_size_xs clearfix"></div>
    <div class="product product_size_xs"></div>
</body>
</html>

Code:

$('.product').removeModifier('size', 'xs');

Result:

<html>
<body>
    <div class="product clearfix"></div>
    <div class="product"></div>
</body>
</html>

Removes the modifier with name and value from a set of elements:

HTML:

<html>
<body>
    <div class="product__name product__name_size_xs clearfix"></div>
    <div class="product__name product__name_size_xs"></div>
</body>
</html>

Code:

$('.product__name').removeModifier('size', 'xs');

Result:

<html>
<body>
    <div class="product__name clearfix"></div>
    <div class="product__name"></div>
</body>
</html>

jQuery.fn.removeModifier(modifiers)

Version added: 1.0.0

Summary

Removes the modifier(s) from each block or element of the current set of jQuery objects. This method retains chaining.

Returns

The current set of jQuery objects.

Type: jQuery object

Parameters

modifiers

A list of modifiers.

Type: Array

Examples

Removes modifiers defined as a list from a set of blocks:

HTML:

<html>
<body>
    <div class="product product_is-selected product_size_xs clearfix"></div>
    <div class="product product_is-selected product_size_xs"></div>
</body>
</html>

Code:

$('.product').removeModifier(
    [{ name: 'is-selected' }, { name: 'size', value: 'xs' }]
);

Result:

<html>
<body>
    <div class="product clearfix"></div>
    <div class="product"></div>
</body>
</html>

Removes modifiers defined as a list from a set of elements:

HTML:

<html>
<body>
    <div class="product__name product__name_is-selected product__name_size_xs clearfix"></div>
    <div class="product__name product__name_is-selected product__name_size_xs"></div>
</body>
</html>

Code:

$('.product__name').removeModifier(
    [{ name: 'is-selected' }, { name: 'size', value: 'xs' }]
);

Result:

<html>
<body>
    <div class="product__name clearfix"></div>
    <div class="product__name"></div>
</body>
</html>

Clone this wiki locally