1 line
9.7 KiB
JSON
1 line
9.7 KiB
JSON
{"name":"hide","type":"method","title":".hide()","deprecated":null,"removed":null,"desc":"Hide the matched elements.","categories":["effects/basics","version/1.0","version/1.4.3"],"entries":[{"return":"jQuery","signatures":[{"added":"1.0"},{"added":"1.0","argument":[{"desc":"A string or number determining how long the animation will run.","type":[{"name":"Number"},{"name":"String"}],"name":"duration","default":"400","optional":"true"},{"desc":"A function to call once the animation is complete.","name":"complete","type":"Function","optional":"true"}]},{"added":"1.0","argument":{"desc":"A map of additional options to pass to the method.","property":[{"desc":"A string or number determining how long the animation will run.","type":[{"name":"Number"},{"name":"String"}],"name":"duration","default":"400"},{"desc":"A string indicating which easing function to use for the transition.","name":"easing","type":"String","default":"swing"},{"desc":"A Boolean indicating whether to place the animation in the effects queue. If false, the animation will begin immediately. <strong>As of jQuery 1.7</strong>, the queue option can also accept a string, in which case the animation is added to the queue represented by that string. When a custom queue name is used the animation does not automatically start; you must call <code>.dequeue(\"queuename\")</code> to start it.","type":[{"name":"Boolean"},{"name":"String"}],"name":"queue","default":"true"},{"desc":"A map of one or more of the CSS properties defined by the properties argument and their corresponding easing functions.","name":"specialEasing","type":"PlainObject","added":"1.4"},{"desc":"A function to be called for each animated property of each animated element. This function provides an opportunity to modify the Tween object to change the value of the property before it is set.","argument":[{"desc":"The numeric value of the property being animated at each step","name":"now","type":"Number"},{"desc":"An object of properties related to the animation and the element being animated. For information about the tween object and its properties, see <ahref=\"/jQuery.Tween/\">jQuery.Tween</a>","name":"tween","type":"Tween"}],"name":"step","type":"Function"},{"desc":"A function to be called after each step of the animation, only once per animated element regardless of the number of animated properties.","argument":[{"desc":"An enhanced Promise object with additional properties for the animation","name":"animation","type":"Promise"},{"desc":"A number from 0 to 1 indicating the progress of the animation","name":"progress","type":"Number"},{"desc":"A number indicating the remaining number of milliseconds until the scheduled end of the animation","name":"remainingMs","type":"Number"}],"name":"progress","type":"Function","added":"1.8"},{"desc":"A function to call once the animation is complete.","name":"complete","type":"Function"},{"desc":"A function to call when the animation begins.","argument":{"desc":"An enhanced Promise object with additional properties for the animation","name":"animation","type":"Promise"},"name":"start","type":"Function","added":"1.8"},{"desc":"A function to be called when the animation completes (its Promise object is resolved).","argument":[{"desc":"An enhanced Promise object with additional properties for the animation","name":"animation","type":"Promise"},{"desc":"Indicates whether the animation jumped to the end","name":"jumpedToEnd","type":"Boolean"}],"name":"done","type":"Function","added":"1.8"},{"desc":"A function to be called when the animation fails to complete (its Promise object is rejected).","argument":[{"desc":"An enhanced Promise object with additional properties for the animation","name":"animation","type":"Promise"},{"desc":"Indicates whether the animation jumped to the end","name":"jumpedToEnd","type":"Boolean"}],"name":"fail","type":"Function","added":"1.8"},{"desc":"A function to be called when the animation completes or stops without completing (its Promise object is either resolved or rejected).","argument":[{"desc":"An enhanced Promise object with additional properties for the animation","name":"animation","type":"Promise"},{"desc":"Indicates whether the animation jumped to the end","name":"jumpedToEnd","type":"Boolean"}],"name":"always","type":"Function","added":"1.8"}],"name":"options","type":"PlainObject"}},{"added":"1.4.3","argument":[{"desc":"A string or number determining how long the animation will run.","type":[{"name":"Number"},{"name":"String"}],"name":"duration","default":"400"},{"desc":"A string indicating which easing function to use for the transition.","name":"easing","type":"String","default":"swing","optional":"true"},{"desc":"A function to call once the animation is complete.","name":"complete","type":"Function","optional":"true"}]}],"examples":[{"desc":"Hides all paragraphs then the link on click.","code":"\n$( \"p\" ).hide();\n$( \"a\" ).click(function( event ) {\n event.preventDefault();\n $( this ).hide();\n});\n","html":"\n<p>Hello</p>\n<a href=\"#\">Click to hide me too</a>\n<p>Here is another paragraph</p>\n"},{"desc":"Animates all shown paragraphs to hide slowly, completing the animation within 600 milliseconds.","code":"\n$( \"button\" ).click(function() {\n $( \"p\" ).hide( \"slow\" );\n});\n","css":"\n p {\n background: #dad;\n font-weight: bold;\n }\n","html":"\n<button>Hide 'em</button>\n<p>Hiya</p>\n<p>Such interesting text, eh?</p>\n"},{"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.","code":"\n$( \"#hider\" ).click(function() {\n $( \"span:last-child\" ).hide( \"fast\", function() {\n // Use arguments.callee so we don't need a named function\n $( this ).prev().hide( \"fast\", arguments.callee );\n });\n});\n$( \"#shower\" ).click(function() {\n $( \"span\" ).show( 2000 );\n});\n","css":"\n span {\n background: #def3ca;\n padding: 3px;\n float: left;\n }\n","html":"\n<button id=\"hider\">Hide</button>\n<button id=\"shower\">Show</button>\n<div>\n <span>Once</span> <span>upon</span> <span>a</span>\n <span>time</span> <span>there</span> <span>were</span>\n <span>three</span> <span>programmers...</span>\n</div>\n"},{"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.","code":"\nfor ( var i = 0; i < 5; i++ ) {\n $( \"<div>\" ).appendTo( document.body );\n}\n$( \"div\" ).click(function() {\n $( this ).hide( 2000, function() {\n $( this ).remove();\n });\n});\n","css":"\n div {\n background: #ece023;\n width: 30px;\n height: 40px;\n margin: 2px;\n float: left;\n }\n","html":"\n<div></div>\n"}],"longdesc":"\n <p>With no parameters, the <code>.hide()</code> method is the simplest way to hide an element:</p>\n <pre><code>\n$( \".target\" ).hide();\n </code></pre>\n <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>\n <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>\n <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>\n <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>\n <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=\"http://jqueryui.com\">jQuery UI suite</a>.</p>\n <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>\n <p>We can animate any element, such as a simple image:</p>\n <pre><code>\n<div id=\"clickme\">\n Click here\n</div>\n<img id=\"book\" src=\"book.png\" alt=\"\" width=\"100\" height=\"123\">\n </code></pre>\n <pre><code>\n// With the element initially shown, we can hide it slowly:\n$( \"#clickme\" ).click(function() {\n $( \"#book\" ).hide( \"slow\", function() {\n alert( \"Animation complete.\" );\n });\n});\n </code></pre>\n <p class=\"image four-across\">\n <img src=\"/resources/0042_06_05.png\" alt=\"\"/>\n <img src=\"/resources/0042_06_06.png\" alt=\"\"/>\n <img src=\"/resources/0042_06_07.png\" alt=\"\"/>\n <img src=\"/resources/0042_06_08.png\" alt=\"\"/>\n </p>\n "}]} |