$className.has
Detect the element has matched class name or not.
$className.has( element, name )
element [object]
The target element.name [string]
The string of class name, separated by blankspace.
Notes
This function is can detect multiple class name for an element.
Example
HTML code
<div id="box" class="aa bb cc dd ee">This is a box</div> <div id="message"></div> <div id="message1"></div> <div id="message2"></div> <div id="message3"></div> <button onclick="start_class_has()">detect class name</button>
JavaScript code
function start_class_has()
{
$text( $("message"), "The box has class name \"aa\": " + $className.has( $("box"), "aa" ) );
$text( $("message1"), "The box has class name \"aa cc\": " + $className.has( $("box"), "aa cc" ) );
$text( $("message2"), "The box has class name \"aa bbc cc\": " + $className.has( $("box"), "aa bbc cc" ) );
$text( $("message3"), "The box has class name \"ee bbc aa\": " + $className.has( $("box"), "ee bbc aa" ) );
}
Demonstration
This is a box