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

Element.addClassName Adds class name to element.

Element.hasClassName Returns a boolean indicating whether element currently has class name (className).

Availability

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

Syntax


  Element.addClassName(element, className);
//or, as of v. 1.5:
  $(element).addClassName(className);

Example


<a href="#" onclick="$('mypara').addClassName('wild'); return false;">
make it wild!</a>

<style type="text/css">
<!--
.wild {
    font: bold 14px/2px 'Helvetica', sans-serif;
    text-transform: lowercase;
    color: #ff0066;
    font-style: italic;
    text-decoration: underline overline;
    text-align: right;
    letter-spacing: 17px;
    word-spacing: 34px;
    background: #ffff00;
    border-top: 5px dotted aquamarine;
    border-bottom: 5px dashed lime;
}
-->
</style>

<p id="mypara">This is going to be wild!</p>

creates:

make it wild!

This is going to be wild!