40 |
aurelien |
1 |
|
|
|
2 |
<ul class="UIAPIPlugin-toc">
|
|
|
3 |
<li><a href="#overview">Overview</a></li>
|
|
|
4 |
<li><a href="#options">Arguments</a></li>
|
|
|
5 |
</ul>
|
|
|
6 |
<div class="UIAPIPlugin">
|
|
|
7 |
<h1>jQuery UI toggleClass</h1>
|
|
|
8 |
<div id="overview">
|
|
|
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/toggleClass?section=1" title="Edit section: toggleClass( class, [duration] )">edit</a>]</div><a name="toggleClass.28_class.2C_.5Bduration.5D_.29"></a><h3>toggleClass( class, <span class="optional">[</span>duration<span class="optional">]</span> )</h3>
|
|
|
12 |
<p>Adds the specified class if it is not present, and removes the specified class if it is present, using an optional transition.</p>
|
|
|
13 |
</div>
|
|
|
14 |
<div id="overview-dependencies">
|
|
|
15 |
<h3>Dependencies</h3>
|
|
|
16 |
<ul>
|
|
|
17 |
<li>Effects Core</li>
|
|
|
18 |
</ul>
|
|
|
19 |
</div>
|
|
|
20 |
<div id="overview-example">
|
|
|
21 |
<h3>Example</h3>
|
|
|
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 'selected' class if it is not present, and removes the 'selected' class if it is present.<br />
|
|
|
26 |
</p>
|
|
|
27 |
<pre>$("p").<a href="http://docs.jquery.com/Events/click" title="Events/click">click</a>(function () {
|
|
|
28 |
$(this).<strong class="selflink">toggleClass</strong>("selected", 1000);
|
|
|
29 |
});
|
|
|
30 |
</pre>
|
|
|
31 |
<p></div><div id="source" class="tabs-container">
|
|
|
32 |
</p>
|
|
|
33 |
<pre><!DOCTYPE html>
|
|
|
34 |
<html>
|
|
|
35 |
<head>
|
|
|
36 |
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
|
|
|
37 |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
|
|
|
38 |
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
|
|
|
39 |
<script src="http://ui.jquery.com/latest/ui/effects.core.js"></script>
|
|
|
40 |
<style type="text/css">
|
|
|
41 |
p { cursor: pointer; font-size: 1.2em; }
|
|
|
42 |
.selected { color:red; }
|
|
|
43 |
</style>
|
|
|
44 |
<script>
|
|
|
45 |
$(document).ready(function() {
|
|
|
46 |
$("p").<a href="http://docs.jquery.com/Events/click" title="Events/click">click</a>(function () {
|
|
|
47 |
$(this).<strong class="selflink">toggleClass</strong>("selected", 1000);
|
|
|
48 |
});
|
|
|
49 |
});
|
|
|
50 |
</script>
|
|
|
51 |
</head>
|
|
|
52 |
<body style="font-size:62.5%;">
|
|
|
53 |
|
|
|
54 |
<p>Click me to toggle 'selected' class.</p>
|
|
|
55 |
<p class="selected">Click me to toggle 'selected' class.</p>
|
|
|
56 |
<p>Click me to toggle 'selected' class.</p>
|
|
|
57 |
|
|
|
58 |
</body>
|
|
|
59 |
</html>
|
|
|
60 |
</pre>
|
|
|
61 |
<p></div>
|
|
|
62 |
</p><p></div>
|
|
|
63 |
</div>
|
|
|
64 |
</div>
|
|
|
65 |
<div id="options">
|
|
|
66 |
<h2 class="top-header">Arguments</h2>
|
|
|
67 |
<ul class="options-list">
|
|
|
68 |
|
|
|
69 |
<li class="option" id="option-class">
|
|
|
70 |
<div class="option-header">
|
|
|
71 |
<h3 class="option-name"><a href="#option-class">class</a></h3>
|
|
|
72 |
<dl>
|
|
|
73 |
<dt class="option-type-label">Type:</dt>
|
|
|
74 |
<dd class="option-type">String</dd>
|
|
|
75 |
|
|
|
76 |
</dl>
|
|
|
77 |
</div>
|
|
|
78 |
<div class="option-description">
|
|
|
79 |
<p>A CSS class to toggle on the elements.</p>
|
|
|
80 |
</div>
|
|
|
81 |
</li>
|
|
|
82 |
|
|
|
83 |
|
|
|
84 |
<li class="option" id="option-duration">
|
|
|
85 |
<div class="option-header">
|
|
|
86 |
<h3 class="option-name"><a href="#option-duration">duration</a></h3>
|
|
|
87 |
<dl>
|
|
|
88 |
<dt class="option-type-label">Type:</dt>
|
|
|
89 |
<dd class="option-type">String, Number</dd>
|
|
|
90 |
|
|
|
91 |
<dt class="option-optional-label">Optional</dt>
|
|
|
92 |
|
|
|
93 |
</dl>
|
|
|
94 |
</div>
|
|
|
95 |
<div class="option-description">
|
|
|
96 |
<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>
|
|
|
97 |
</div>
|
|
|
98 |
</li>
|
|
|
99 |
|
|
|
100 |
</ul>
|
|
|
101 |
</div>
|
|
|
102 |
</div>
|
|
|
103 |
|
|
|
104 |
</p><!--
|
|
|
105 |
Pre-expand include size: 5271 bytes
|
|
|
106 |
Post-expand include size: 7027 bytes
|
|
|
107 |
Template argument size: 4437 bytes
|
|
|
108 |
Maximum: 2097152 bytes
|
|
|
109 |
-->
|
|
|
110 |
|
|
|
111 |
<!-- Saved in parser cache with key jqdocs_docs:pcache:idhash:2608-1!1!0!!en!2 and timestamp 20100910025514 -->
|