02.06.2013 Views

DOM Traversal Methods

DOM Traversal Methods

DOM Traversal Methods

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

.fadeOut()<br />

Hides the matched elements by fading them to transparent.<br />

.fadeOut([speed][, callback])<br />

[ 143 ]<br />

Chapter 6<br />

Parameters<br />

• speed (optional): A string or number determining how long the animation<br />

will run<br />

•<br />

callback (optional): A function to call once the animation is complete<br />

Return Value<br />

The jQuery object, for chaining purposes.<br />

Description<br />

The .fadeOut() method animates the opacity of the matched elements.<br />

Speeds are given in millisecond durations of the animation; higher values indicate<br />

slower animations, not faster ones. The strings fast, normal, and slow can be<br />

supplied to indicate speed values of 200, 400, and 600 respectively. If the speed<br />

parameter is omitted, normal is assumed.<br />

If supplied, the callback is fired once the animation is complete. This can be useful<br />

for stringing different animations together in sequence. The callback is not sent any<br />

arguments, but this is set to the <strong>DOM</strong> element being animated. The callback is<br />

executed once per matched element, not once for the animation as a whole.<br />

We can animate any element, such as a simple containing an image:<br />

<br />

Trigger<br />

<br />

<br />

<br />

With the element initially displayed, we can hide it slowly:<br />

$('.trigger').click(function() {<br />

$('.target').fadeOut('slow', function() {<br />

$(this).log('Effect complete.');<br />

});<br />

});

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!