2
<ul class="UIAPIPlugin-toc">
3
<li><a href="#overview">Overview</a></li>
4
<li><a href="#options">Arguments</a></li>
6
<div class="UIAPIPlugin">
7
<h1>jQuery UI addClass</h1>
9
<h2 class="top-header">Overview</h2>
10
<div id="overview-main">
11
<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://docs.jquery.com/action/edit/UI/Effects/addClass?section=1" title="Edit section: addClass( class, [duration] )">edit</a>]</div><a name="addClass.28_class.2C_.5Bduration.5D_.29"></a><h3>addClass( class, <span class="optional">[</span>duration<span class="optional">]</span> )</h3>
12
<p>Adds the specified class to each of the set of matched elements with an optional transition between the states.</p>
14
<div id="overview-dependencies">
20
<div id="overview-example">
22
<div id="overview-example" class="example">
23
<ul><li><a href="#demo"><span>Demo</span></a></li><li><a href="#source"><span>View Source</span></a></li></ul>
24
<p><div id="demo" class="tabs-container" rel="100">
25
Adds the class 'selected' to the matched elements with a one second transition.<br />
27
<pre>$("p").<a href="http://docs.jquery.com/Events/click" title="Events/click">click</a>(function () {
28
$(this).<strong class="selflink">addClass</strong>("selected", 1000);
31
<p></div><div id="source" class="tabs-container">
33
<pre><!DOCTYPE html>
36
<link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" />
37
<script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
38
<script src="http://ui.jquery.com/latest/ui/effects.core.js"></script>
39
<style type="text/css">
40
p { cursor: pointer; font-size: 1.2em; }
41
.selected { color:red; }
43
<script type="text/javascript">
44
$(document).ready(function(){
45
$("p").<a href="http://docs.jquery.com/Events/click" title="Events/click">click</a>(function () {
46
$(this).<strong class="selflink">addClass</strong>("selected", 1000);
51
<body style="font-size:62.5%;">
52
<p>Click me to add a 'selected' class.</p>
53
<p>Click me to add a 'selected' class.</p>
54
<p>Click me to add a 'selected' class.</p>
63
<h2 class="top-header">Arguments</h2>
64
<ul class="options-list">
66
<li class="option" id="option-class">
67
<div class="option-header">
68
<h3 class="option-name"><a href="#option-class">class</a></h3>
70
<dt class="option-type-label">Type:</dt>
71
<dd class="option-type">String</dd>
75
<div class="option-description">
76
<p>One CSS class to add to the elements.</p>
81
<li class="option" id="option-duration">
82
<div class="option-header">
83
<h3 class="option-name"><a href="#option-duration">duration</a></h3>
85
<dt class="option-type-label">Type:</dt>
86
<dd class="option-type">String, Number</dd>
88
<dt class="option-optional-label">Optional</dt>
92
<div class="option-description">
93
<p>A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).</p>
102
Pre-expand include size: 5085 bytes
103
Post-expand include size: 6833 bytes
104
Template argument size: 4275 bytes
105
Maximum: 2097152 bytes
108
<!-- Saved in parser cache with key jqdocs_docs:pcache:idhash:2606-1!1!0!!en!2 and timestamp 20090318030446 -->