| 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>$("p").<a href="http://docs.jquery.com/Events/click" title="Events/click">click</a>(function () { |
| 28 |
$(this).<strong class="selflink">switchClass</strong>("highlight", "blue", 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 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 { margin: 4px; font-size:16px; font-weight:bolder; |
| 41 |
cursor:pointer; } |
| 42 |
.blue { background: blue; } |
| 43 |
.highlight { background:yellow; } |
| 44 |
</style> |
| 45 |
<script type="text/javascript"> |
| 46 |
$(document).ready(function(){ |
| 47 |
$("p").<a href="http://docs.jquery.com/Events/click" title="Events/click">click</a>(function () { |
| 48 |
$(this).<strong class="selflink">switchClass</strong>("highlight", "blue", 1000); |
| 49 |
}); |
| 50 |
}); |
| 51 |
</script> |
| 52 |
</head> |
| 53 |
<body style="font-size:62.5%;"> |
| 54 |
|
| 55 |
<p class="highlight">Click to switch</p> |
| 56 |
<p class="highlight">to blue</p> |
| 57 |
<p class="highlight">on these</p> |
| 58 |
<p class="highlight">paragraphs</p> |
| 59 |
|
| 60 |
</body> |
| 61 |
</html> |
| 62 |
</pre> |
| 63 |
<p></div> |
| 64 |
</p><p></div> |
| 65 |
</div> |
| 66 |
</div> |
| 67 |
<div id="options"> |
| 68 |
<h2 class="top-header">Arguments</h2> |
| 69 |
<ul class="options-list"> |
| 70 |
|
| 71 |
<li class="option" id="option-remove"> |
| 72 |
<div class="option-header"> |
| 73 |
<h3 class="option-name"><a href="#option-remove">remove</a></h3> |
| 74 |
<dl> |
| 75 |
<dt class="option-type-label">Type:</dt> |
| 76 |
<dd class="option-type">String</dd> |
| 77 |
|
| 78 |
</dl> |
| 79 |
</div> |
| 80 |
<div class="option-description"> |
| 81 |
<p>The CSS class that will be removed.</p> |
| 82 |
</div> |
| 83 |
</li> |
| 84 |
|
| 85 |
|
| 86 |
<li class="option" id="option-add"> |
| 87 |
<div class="option-header"> |
| 88 |
<h3 class="option-name"><a href="#option-add">add</a></h3> |
| 89 |
<dl> |
| 90 |
<dt class="option-type-label">Type:</dt> |
| 91 |
<dd class="option-type">String</dd> |
| 92 |
|
| 93 |
</dl> |
| 94 |
</div> |
| 95 |
<div class="option-description"> |
| 96 |
<p>The CSS class that will be added.</p> |
| 97 |
</div> |
| 98 |
</li> |
| 99 |
|
| 100 |
|
| 101 |
<li class="option" id="option-duration"> |
| 102 |
<div class="option-header"> |
| 103 |
<h3 class="option-name"><a href="#option-duration">duration</a></h3> |
| 104 |
<dl> |
| 105 |
<dt class="option-type-label">Type:</dt> |
| 106 |
<dd class="option-type">String, Number</dd> |
| 107 |
|
| 108 |
<dt class="option-optional-label">Optional</dt> |
| 109 |
|
| 110 |
</dl> |
| 111 |
</div> |
| 112 |
<div class="option-description"> |
| 113 |
<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> |
| 114 |
</div> |
| 115 |
</li> |
| 116 |
|
| 117 |
</ul> |
| 118 |
</div> |
| 119 |
</div> |
| 120 |
|
| 121 |
</p><!-- |
| 122 |
Pre-expand include size: 5655 bytes |
| 123 |
Post-expand include size: 7540 bytes |
| 124 |
Template argument size: 4741 bytes |
| 125 |
Maximum: 2097152 bytes |
| 126 |
--> |
| 127 |
|
| 128 |
<!-- Saved in parser cache with key jqdocs_docs:pcache:idhash:2609-1!1!0!!en!2 and timestamp 20090604041109 --> |
| 129 |
|