Book Image

Mastering jQuery

By : Alex Libby
Book Image

Mastering jQuery

By: Alex Libby

Overview of this book

<p>Mastering jQuery has been written not only to help maximize your skills with core functionality in the library, but also to explore some of the more intriguing ways of using the library to achieve real-world solutions that could feature on any website or online environment.</p> <p>You'll start with a look at some of the more advanced ways to incorporate the library into your pages, followed by working with forms and advanced form validation using regular expressions. Next you'll move on to animating in jQuery, advanced event handling, and using jQuery effects.</p> <p>Finally, you will develop practical examples of using jQuery with external functionality such as node-webkit, before finishing with a session on optimizing your version of the library for maximum efficiency and exploring best practices for using QUnit.</p>
Table of Contents (21 chapters)
Mastering jQuery
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating custom effects


If you've spent any time applying effects to animated elements, then you will very likely have used .animate(), or one of the shortcut methods, such as .fadeIn(), .show(), or .slideUp(). All of them follow a similar format, where we need to provide at least a duration, type of easing, and potentially a callback function to either perform a task when the animation has completed, or log something to the console to this effect.

All too often though, we may decide to stick with the standard values such as slow, fast, or perhaps a numerical value such as 500:

$("button").click(function() {
  $("p").slideToggle("slow");
});

There is absolutely nothing wrong with using this approach - except, it's very boring, and only using a fraction of what is possible.

Over the next few pages, we'll explore some of the tricks available to broaden our knowledge when applying effects, and realize that we don't always have to stick with the tried and tested methods. Before we explore some of...