Project

General

Profile

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 switchClass</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/switchClass?section=1" title="Edit section: switchClass( remove, add, [duration] )">edit</a>]</div><a name="switchClass.28_remove.2C_add.2C_.5Bduration.5D_.29"></a><h3>switchClass( remove, add, <span class="optional">[</span>duration<span class="optional">]</span> )</h3>
12
<p>Switches from the class defined in the first argument to the class defined as second argument, 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="170">
25
Switch the class 'highlight' to 'blue' when a paragraph is clicked with a one second transition.<br />
26
</p>
27
<pre>$(&quot;p&quot;).<a href="http://docs.jquery.com/Events/click" title="Events/click">click</a>(function () {
28
      $(this).<strong class="selflink">switchClass</strong>(&quot;highlight&quot;, &quot;blue&quot;, 1000);
29
    });
30
</pre>
31
<p></div><div id="source" class="tabs-container">
32
</p>
33
<pre>&lt;!DOCTYPE html&gt;
34
&lt;html&gt;
35
&lt;head&gt;
36
  &lt;link href=&quot;http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;/&gt;
37
  &lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js&quot;&gt;&lt;/script&gt;
38
  &lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js&quot;&gt;&lt;/script&gt;
39
  &lt;script src=&quot;http://ui.jquery.com/latest/ui/effects.core.js&quot;&gt;&lt;/script&gt;
40
&lt;style type=&quot;text/css&quot;&gt;
41
  p { margin: 4px; font-size:16px; font-weight:bolder; 
42
      cursor:pointer; }
43
  .blue { background: blue; }
44
  .highlight { background:yellow; }
45
&lt;/style&gt;
46
  &lt;script&gt;
47
  $(document).ready(function() {
48
    $(&quot;p&quot;).<a href="http://docs.jquery.com/Events/click" title="Events/click">click</a>(function () {
49
      $(this).<strong class="selflink">switchClass</strong>(&quot;highlight&quot;, &quot;blue&quot;, 1000);
50
    });
51
  });
52
  &lt;/script&gt;
53
&lt;/head&gt;
54
&lt;body style="font-size:62.5%;"&gt;
55
  
56
&lt;p class=&quot;highlight&quot;&gt;Click to switch&lt;/p&gt;
57
&lt;p class=&quot;highlight&quot;&gt;to blue&lt;/p&gt;
58
&lt;p class=&quot;highlight&quot;&gt;on these&lt;/p&gt;
59
&lt;p class=&quot;highlight&quot;&gt;paragraphs&lt;/p&gt;
60

    
61
&lt;/body&gt;
62
&lt;/html&gt;
63
</pre>
64
<p></div>
65
</p><p></div>
66
    </div>
67
  </div>
68
  <div id="options">
69
    <h2 class="top-header">Arguments</h2>
70
    <ul class="options-list">
71
      
72
<li class="option" id="option-remove">
73
  <div class="option-header">
74
    <h3 class="option-name"><a href="#option-remove">remove</a></h3>
75
    <dl>
76
      <dt class="option-type-label">Type:</dt>
77
        <dd class="option-type">String</dd>
78
      
79
    </dl>
80
  </div>
81
  <div class="option-description">
82
    <p>The CSS class that will be removed.</p>
83
  </div>
84
</li>
85

    
86

    
87
<li class="option" id="option-add">
88
  <div class="option-header">
89
    <h3 class="option-name"><a href="#option-add">add</a></h3>
90
    <dl>
91
      <dt class="option-type-label">Type:</dt>
92
        <dd class="option-type">String</dd>
93
      
94
    </dl>
95
  </div>
96
  <div class="option-description">
97
    <p>The CSS class that will be added.</p>
98
  </div>
99
</li>
100

    
101

    
102
<li class="option" id="option-duration">
103
  <div class="option-header">
104
    <h3 class="option-name"><a href="#option-duration">duration</a></h3>
105
    <dl>
106
      <dt class="option-type-label">Type:</dt>
107
        <dd class="option-type">String, Number</dd>
108
      
109
      <dt class="option-optional-label">Optional</dt>
110
      
111
    </dl>
112
  </div>
113
  <div class="option-description">
114
    <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>
115
  </div>
116
</li>
117

    
118
    </ul>
119
  </div>
120
</div>
121

    
122
</p><!-- 
123
Pre-expand include size: 5798 bytes
124
Post-expand include size: 7570 bytes
125
Template argument size: 4751 bytes
126
Maximum: 2097152 bytes
127
-->
128

    
129
<!-- Saved in parser cache with key jqdocs_docs:pcache:idhash:2609-1!1!0!!en!2 and timestamp 20101025053924 -->
(20-20/23)