02.06.2013 Views

jQuery 1.4 Animation Techniques - Index of

jQuery 1.4 Animation Techniques - Index of

jQuery 1.4 Animation Techniques - Index of

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

2. Save the changes as toggle.html.<br />

[ 53 ]<br />

Chapter 2<br />

3. We should find when we run the page that it works in the same way as it did using<br />

the show() and hide() methods. In this example, using the toggle() method<br />

has done nothing for us; we haven't reduced our own code at all.<br />

4. In some applications, if we were using the click event to either show or hide an<br />

element for example, we would be able to reduce the complexity <strong>of</strong> our event<br />

handlers and rely on toggle() to do it for us.<br />

Have a go hero – doing more with toggle<br />

Why not change the last two examples so that the vertical menu uses click events<br />

instead <strong>of</strong> hover events. You'll get to see when toggle() can be used to simplify your code.<br />

Summary<br />

In this chapter, we looked at some <strong>of</strong> <strong>jQuery</strong>'s most basic animation methods. The fade class<br />

<strong>of</strong> methods are the simplest animation methods found in <strong>jQuery</strong>, animating nothing except<br />

the opacity <strong>of</strong> the selected element(s).<br />

The show(), hide(), and toggle() methods can also be used to perform animations but<br />

alter the dimensions <strong>of</strong> the element as well as its opacity. All <strong>of</strong> these methods are simple to<br />

use and require few or no additional configuration in order to run.<br />

We looked at the following methods in this chapter:<br />

fadeIn()<br />

fadeOut()<br />

fadeTo()<br />

fadeToggle()<br />

show()<br />

hide()<br />

toggle()

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

Saved successfully!

Ooh no, something went wrong!