Prototype This page is part of the Prototype JavaScript framework documentation.
Overview | (...)

Element.has\ClassName Returns true if element has a class name corresponding to className and false otherwise.

Availability

script.aculo.us V1.5_rc5
Prototype V1.4.0_rc3

Syntax


  Element.hasClassName(element, className);

Examples


<a href="#" onclick="alert(Element.hasClassName('test', 'fantastic')); return false;">
does the below paragraph's class correspond to "fantastic"?</a>

<p id="test" class="fantastic">This is the best paragraph ever written!</p>

creates:

does the below paragraph's class correspond to "fantastic"?

This is the best paragraph ever written!


<a href="#" onclick="alert(Element.hasClassName('test2', 'fantastic')); return false;">
does the below paragraph's class correspond to "fantastic"?</a>

<p id="test2" class="gross">This is a truly horrible piece of writting!</p>

creates:

does the below paragraph's class correspond to "fantastic"?

This is a truly horrible piece of writting!