02.06.2013 Views

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Figure 2-20. Using .each(), the expected results are produced<br />

Using Animation <strong>and</strong> Other Effects<br />

CHAPTER 2 ■ COMMON JQUERY ACTIONS AND METHODS<br />

One of the most exciting features of <strong>jQuery</strong> is its library of methods that allow for animation <strong>and</strong> special<br />

effects, which are all possible with plain JavaScript but are incredibly easy using <strong>jQuery</strong>. A traditional<br />

JavaScript approach is tricky <strong>and</strong> much more involved.<br />

■ Note Because it’s difficult to show animations as static images, you’ll need to rely on your browser for an<br />

illustration of how these examples should look. For live demonstrations of the different animation effects, visit the<br />

<strong>jQuery</strong> API at http://api.jquery.com, <strong>and</strong> look up the individual method you wish to see demonstrated.<br />

.show() <strong>and</strong> .hide()<br />

The most basic effects functions are .show() <strong>and</strong> .hide(). When fired without a parameter, they simply<br />

add or remove display:none; from the element’s style attribute.<br />

Hide the paragraph with ID bar using the following:<br />

$("#bar").hide();<br />

65

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

Saved successfully!

Ooh no, something went wrong!