-
Notifications
You must be signed in to change notification settings - Fork 264
/
Copy pathhide.xml
159 lines (158 loc) · 7.05 KB
/
hide.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?xml version="1.0"?>
<entry type="method" name="hide" return="jQuery">
<title>.hide()</title>
<desc>Hide the matched elements.</desc>
<signature>
<added>1.0</added>
</signature>
<signature>
<added>1.0</added>
<xi:include href="../includes/duration-argument.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
<xi:include href="../includes/complete-argument.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
</signature>
<signature>
<added>1.0</added>
<xi:include href="../includes/options-argument.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
</signature>
<signature>
<added>1.4.3</added>
<!-- doesn't use the include because duration is required for this signature -->
<argument name="duration" default="400">
<desc>A string or number determining how long the animation will run.</desc>
<type name="Number"/>
<type name="String"/>
</argument>
<xi:include href="../includes/easing-argument.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
<xi:include href="../includes/complete-argument.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
</signature>
<longdesc>
<p>With no parameters, the <code>.hide()</code> method is the simplest way to hide an element:</p>
<pre><code>
$( ".target" ).hide();
</code></pre>
<p>The matched elements will be hidden immediately, with no animation. This is roughly equivalent to calling <code>.css( "display", "none" )</code>, except that the value of the <code>display</code> property is saved in jQuery's data cache so that <code>display</code> can later be restored to its initial value. If an element has a <code>display</code> value of <code>inline</code> and is hidden then shown, it will once again be displayed <code>inline</code>.</p>
<p>When a duration, a plain object, or a "complete" function is provided, <code>.hide()</code> becomes an animation method. The <code>.hide()</code> method animates the width, height, and opacity of the matched elements simultaneously. When these properties reach 0, the <code>display</code> style property is set to <code>none</code> to ensure that the element no longer affects the layout of the page.</p>
<p>Durations are given in milliseconds; higher values indicate slower animations, not faster ones. The strings <code>'fast'</code> and <code>'slow'</code> can be supplied to indicate durations of <code>200</code> and <code>600</code> milliseconds, respectively.</p>
<p>Note that <code>.hide()</code> is fired immediately and will override the animation queue if no duration or a duration of 0 is specified.</p>
<p>As of jQuery <strong>1.4.3</strong>, an optional string naming an easing function may be used. Easing functions specify the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default, called <code>swing</code>, and one that progresses at a constant pace, called <code>linear</code>. More easing functions are available with the use of plug-ins, most notably the <a href="https://jqueryui.com">jQuery UI suite</a>.</p>
<p>If supplied, the callback is fired once the animation is complete. This can be useful for stringing different animations together in sequence. The callback is not sent any arguments, but <code>this</code> is set to the DOM element being animated. If multiple elements are animated, it is important to note that the callback is executed once per matched element, not once for the animation as a whole.</p>
<div class="warning">
<p><strong>Note:</strong> This method may cause performance issues, especially when used on many elements. If you're encountering such issues, use performance testing tools to determine whether this method is causing them. Moreover, this method can cause problems with responsive layouts if the display value differs at different viewport sizes.</p>
</div>
<p>We can animate any element, such as a simple image:</p>
<pre><code>
<div id="clickme">
Click here
</div>
<img id="book" src="book.png" alt="" width="100" height="123">
</code></pre>
<pre><code>
// With the element initially shown, we can hide it slowly:
$( "#clickme" ).on( "click", function() {
$( "#book" ).hide( "slow", function() {
alert( "Animation complete." );
});
});
</code></pre>
<figure>
<img class="column three" src="/resources/0042_06_05.png" alt=""/>
<img class="column three" src="/resources/0042_06_06.png" alt=""/>
<img class="column three" src="/resources/0042_06_07.png" alt=""/>
<img class="column three" src="/resources/0042_06_08.png" alt=""/>
<figcaption>Figure 1 - Illustration of the <code>hide()</code> effect</figcaption>
</figure>
</longdesc>
<note id="jquery.fx.off" type="additional" data-title=".hide()"/>
<example>
<desc>Hides all paragraphs then the link on click.</desc>
<code><![CDATA[
$( "p" ).hide();
$( "a" ).on( "click", function( event ) {
event.preventDefault();
$( this ).hide();
});
]]></code>
<html><![CDATA[
<p>Hello</p>
<a href="#">Click to hide me too</a>
<p>Here is another paragraph</p>
]]></html>
</example>
<example>
<desc>Animates all shown paragraphs to hide slowly, completing the animation within 600 milliseconds.</desc>
<code><![CDATA[
$( "button" ).on( "click", function() {
$( "p" ).hide( "slow" );
});
]]></code>
<css><![CDATA[
p {
background: #dad;
font-weight: bold;
}
]]></css>
<html><![CDATA[
<button>Hide 'em</button>
<p>Hiya</p>
<p>Such interesting text, eh?</p>
]]></html>
</example>
<example>
<desc>Animates all spans (words in this case) to hide fastly, completing each animation within 200 milliseconds. Once each animation is done, it starts the next one.</desc>
<code><![CDATA[
$( "#hider" ).on( "click", function() {
$( "span:last-child" ).hide( "fast", function() {
// Use arguments.callee so we don't need a named function
$( this ).prev().hide( "fast", arguments.callee );
});
});
$( "#shower" ).on( "click", function() {
$( "span" ).show( 2000 );
});
]]></code>
<css><![CDATA[
span {
background: #def3ca;
padding: 3px;
float: left;
}
]]></css>
<html><![CDATA[
<button id="hider">Hide</button>
<button id="shower">Show</button>
<div>
<span>Once</span> <span>upon</span> <span>a</span>
<span>time</span> <span>there</span> <span>were</span>
<span>three</span> <span>programmers...</span>
</div>
]]></html>
</example>
<example>
<desc>Hides the divs when clicked over 2 seconds, then removes the div element when its hidden. Try clicking on more than one box at a time.</desc>
<code><![CDATA[
for ( var i = 0; i < 5; i++ ) {
$( "<div>" ).appendTo( document.body );
}
$( "div" ).on( "click", function() {
$( this ).hide( 2000, function() {
$( this ).remove();
});
});
]]></code>
<css><![CDATA[
div {
background: #ece023;
width: 30px;
height: 40px;
margin: 2px;
float: left;
}
]]></css>
<html><![CDATA[
<div></div>
]]></html>
</example>
<category slug="effects/basics"/>
<category slug="version/1.0"/>
<category slug="version/1.4.3"/>
</entry>