Method _.Class.exists
Summary:
Checks if a class or any values in an array of classes exists on an element.
- Calling Convention:
-
_.Class.exists(Element, [String || Array])
- Parameters:
-
- Element
- The element to check for presence of classes
- String
- A string to be searched for in Element.className
- Array
- An array of strings to be searched for.
- Returns:
- True if at least one class is present.
- False if no classes are present
Example
HTML:
<p id="test" class="one"></p>
JavaScript:
var p = document.getElementById('test');
console.log('p# test contains "one" is ' + _.Class.exists(p, 'one'));
console.log('p# test contains "two" is ' + _.Class.exists(p, 'two'));
console.log('p# test contains "one" or "two" is ' + _.Class.exists(p, ['one', 'two']));