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

Converting animations to use CSS3 automatically


We've built a tooltip plugin which uses a touch of animation to fade in and out when hovering over elements marked with the .tooltip class. Nothing wrong in that – the code works perfectly well, and is an acceptable way of displaying content…right? Wrong! As you should know by now, we can definitely do better. Here's why I chose the tooltip as our example.

Remember how I mentioned back in Chapter 6, Animating in jQuery, that we should consider using CSS3 styling to control our animation? Well, here's a perfect example: we can easily change our code to force jQuery to use CSS3 where possible, or fall back to using the library for older browsers.

The trick behind it is in one line:

<script src="js/jquery.animate-enhanced.min.js"></script>

To see how easy it is, follow the next steps:

  1. In a copy of tooltipv2.html, add this line as indicated:

      <script src="js/jquery.min.js"></script>
      <script src="js/jquery.animate-enhanced...