Started

Selectors

Utilities

Animation

AJAX

CSS

Event

Manipulation

Cookie

String

Attributes

Data

Storage

Miscellaneous

$className.set

Directly set the class name for a element.
$className.set( element, name )
  1. element [object]
    The target element.
  2. name [string]
    The string of class name.

Notes

This function is to set the whole of class name property of the element, which is much more efficient to change the class directly.

Example

HTML code
<div id="box">This is a box</div>
<button onclick="start_class_set()">Add class name to the box</button>
CSS code
.css1 {
	border:1px solid #333;
	padding: 10px;
}
.css2 {
	background: #5599bb;
}
.css3 {
	font-size: 24px;
}
JavaScript code
function start_class_set()
{
	$className.set($("box"), "css1 css2 css3");
}
Demonstration
This is a box