Skip to content

.toggleModifier()

esr360 edited this page May 1, 2019 · 2 revisions

Toggle one or more modifiers to each element in the set of matched elements (add the modifier if not already present/remove the modifier if present)

.toggleModifier(modifier, config);
Aliases
  • .toggle()
  • .toggleModifiers()
Param Type Info
modifier (String|Array) The modifier(s) to toggle on each element in the set of matched elements
[config] Object The configuration to use when calling the method (learn more)

Example With Single Modifier

<div class="button" id="alpha">Button</div>
sQuery('#alpha').toggleModifier('active');
Result
<div class="button-active" id="alpha">Button</div>

Example With Multiple Modifiers

<div class="button" id="alpha">Button</div>

Note the use of .toggleModifiers() alias

sQuery('#alpha').toggleModifier(['disabled', 'error']);
Result
<div class="button-disabled-error" id="alpha">Button</div>
Clone this wiki locally