Elementals.js

Latest Version: 3.0 RC 1 17 July 2017

Method _.Class.remove

Summary:

Removes a class or array of classes from an Element.

Calling Convention:
_.Class.remove(Element, [String || Array])
Parameters:
Element
The element to remove classes from
String
A string containing a single class to be removed
Array
An array of class strings to be removed
Returns:
True if at least one class was removed.
False if no classes were removed

Example #1 -- String

HTML:

<p id="test" class="one"></p>

JavaScript:

var p = document.getElementById('test');
_.Class.remove(p, 'one');
// p#test no longer has the class 'one' on it.

Example #2 -- Array

HTML:

<p id="test" class="one two three"></p>

JavaScript:

var p = document.getElementById('test');
alert(_.Class.remove(p, ['one', 'three', 'four');
// p#test now only has class="two" on it.
// the alert will say true as classes were removed

Advertisement