{"name":"fadeOut","type":"method","title":".fadeOut()","deprecated":null,"removed":null,"desc":"Hide the matched elements by fading them to transparent.","categories":["effects/fading","version/1.0","version/1.4.3"],"entries":[{"return":"jQuery","signatures":[{"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. As of jQuery 1.7, 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 .dequeue(\"queuename\") 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 jQuery.Tween","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","optional":"true"},{"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":"Animates all paragraphs to fade out, completing the animation within 600 milliseconds.","code":"\n$( \"p\" ).click(function() {\n $( \"p\" ).fadeOut( \"slow\" );\n});\n","css":"\n p {\n font-size: 150%;\n cursor: pointer;\n }\n","html":"\n

\n If you click on this paragraph\n you'll see it just fade away.\n

\n"},{"desc":"Fades out spans in one section that you click on.","code":"\n$( \"span\" ).click(function() {\n $( this ).fadeOut( 1000, function() {\n $( \"div\" ).text( \"'\" + $( this ).text() + \"' has faded!\" );\n $( this ).remove();\n });\n});\n$( \"span\" ).hover(function() {\n $( this ).addClass( \"hilite\" );\n}, function() {\n $( this ).removeClass( \"hilite\" );\n});\n","css":"\n span {\n cursor: pointer;\n }\n span.hilite {\n background: yellow;\n }\n div {\n display: inline;\n color: red;\n }\n","html":"\n

Find the modifiers -

\n

\n If you really want to go outside\n in the cold then make sure to wear\n your warm jacket given to you by\n your favorite teacher.\n

\n"},{"desc":"Fades out two divs, one with a \"linear\" easing and one with the default, \"swing,\" easing.","code":"\n$( \"#btn1\" ).click(function() {\n function complete() {\n $( \"
\" ).text( this.id ).appendTo( \"#log\" );\n }\n $( \"#box1\" ).fadeOut( 1600, \"linear\", complete );\n $( \"#box2\" ).fadeOut( 1600, complete );\n});\n\n$( \"#btn2\" ).click(function() {\n $( \"div\" ).show();\n $( \"#log\" ).empty();\n});\n","css":"\n .box,\n button {\n float: left;\n margin: 5px 10px 5px 0;\n }\n .box {\n height: 80px;\n width: 80px;\n background: #090;\n }\n #log {\n clear: left;\n }\n","html":"\n\n\n\n
\n\n
linear
\n
swing
\n"}],"longdesc":"\n

The .fadeOut() method animates the opacity of the matched elements. Once the opacity reaches 0, the display style property is set to none, so the element no longer affects the layout of the page.

\n

Durations are given in milliseconds; higher values indicate slower animations, not faster ones. The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 milliseconds, respectively. If any other string is supplied, or if the duration parameter is omitted, the default duration of 400 milliseconds is used.

\n

We can animate any element, such as a simple image:

\n
\n<div id=\"clickme\">\n  Click here\n</div>\n<img id=\"book\" src=\"book.png\" alt=\"\" width=\"100\" height=\"123\">\n    
\n

With the element initially shown, we can hide it slowly:

\n
\n$( \"#clickme\" ).click(function() {\n  $( \"#book\" ).fadeOut( \"slow\", function() {\n    // Animation complete.\n  });\n});\n    
\n

\n \"\"/\n \"\"/\n \"\"/\n \"\"/\n

\n
\n

Note: To avoid unnecessary DOM manipulation, .fadeOut() will not hide an element that is already considered hidden. For information on which elements jQuery considers hidden, see :hidden Selector.

\n
\n

Easing

\n

As of jQuery 1.4.3, 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 swing, and one that progresses at a constant pace, called linear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.

\n

Callback Function

\n

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 this 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.

\n

As of jQuery 1.6, the .promise() method can be used in conjunction with the deferred.done() method to execute a single callback for the animation as a whole when all matching elements have completed their animations ( See the example for .promise() ).

\n "}]}