Started

Selectors

Utilities

Animation

AJAX

CSS

Event

Manipulation

Cookie

String

Attributes

Data

Storage

Miscellaneous

$className.add

Add a class name for a element.
$className.add( element, name )
  1. element [object]
    The target element.
  2. name [string]
    The target class name.

Notes

This function is useful to add class name for element to attach CSS class style to it.

Example

HTML code
<div id="box1">This is a box</div>
<button onclick="start_class_add()">Add class name to the box</button>
CSS code
.box {
	width: 200px;
	height: 60px;
	font-size: 12px;
	background: #5599bb;
	padding: 10px;
}
JavaScript code
function start_class_add()
{
	$className.add($("box1"), "box");
}
Demonstration
This is a box