Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
jQuery 1.4 Animation Techniques: Beginners Guide

You're reading from  jQuery 1.4 Animation Techniques: Beginners Guide

Product type Book
Published in Mar 2011
Publisher Packt
ISBN-13 9781849513302
Pages 344 pages
Edition 1st Edition
Languages
Concepts

Table of Contents (19) Chapters

jQuery 1.4 Animation Techniques Beginner's Guide
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Introduction 2. Fading Animations 3. Managing Animations 4. Sliding Animations 5. Custom Animations 6. Extended Animations with jQuery UI 7. Full Page Animations 8. Other Popular Animations 9. CSS3 Animations 10. Canvas Animations Pop Quiz Answers Index

Time for action – exploding an element


In this example we will make an image explode.

  1. Just add the following simple image to the <body> of the template file:

    <img src="img/grenade.jpg" alt="Grenade">
  2. Then add the following equally simple code to the empty function at the bottom of the template file:

    $("img").click(function() {
      $(this).effect("explode");
    });
  3. Save this page as explode.html.

  4. This example is so simple we don't even need a stylesheet. Once we click on the grenade, it is exploded into the default number of pieces:

The exploded element fades away as the individual pieces of the element move apart.

What just happened?

In the example, all we need to do is attach a click handler directly to the image which applies the explode effect using the effect() method. No configuration in this instance is required because the default mode of the effect is hide.

Note that we can also run this effect in reverse by setting the mode option to show, or using the show() logic instead. In this...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}