Book Image

Learning jQuery : Better Interaction Design and Web Development with Simple JavaScript Techniques

Book Image

Learning jQuery : Better Interaction Design and Web Development with Simple JavaScript Techniques

Overview of this book

Table of Contents (18 chapters)
Learning jQuery
About the Authors
About the Reviewers


jQuery is a powerful JavaScript library that can enhance your websites regardless of your background.

Created by John Resig, jQuery is an open-source project with a dedicated core team of top-notch JavaScript developers. It provides a wide range of features, an easy-to-learn syntax, and robust cross-platform compatibility in a single compact file. What’s more, over a hundred plug-ins have been developed to extend jQuery’s functionality, making it an essential tool for nearly every client-side scripting occasion.

Learning jQuery provides a gentle introduction to jQuery concepts, allowing you to add interactions and animations to your pages—even if previous attempts at writing JavaScript have left you baffled. This book guides you past the pitfalls associated with AJAX, events, effects, and advanced JavaScript language features.

A working demo of the examples in this book is available at:

What This Book Covers

The first part of the book introduces jQuery and helps you to understand what the fuss is all about. Chapter 1 covers downloading and setting up the jQuery library, as well as writing your first script.

The second part of the book steps you through each of the major aspects of the jQuery library. In Chapter 2 , you’ll learn how to get anything you want. The selector expressions in jQuery allow you to find elements on the page, wherever they may be. You’ll work with these selector expressions to apply styling to a diverse set of page elements, sometimes in a way that pure CSS cannot.

In Chapter 3 , you’ll learn how to pull the trigger. You will use jQuery’s event-handling mechanism to fire off behaviors when browser events occur. You’ll also get the inside scoop on jQuery’s secret sauce: attaching events unobtrusively, even before the page finishes loading.

In Chapter 4 , you’ll learn how to add flair to your actions. You’ll be introduced to jQuery’s animation techniques and see how to hide, show, and move page elements with the greatest of ease.

In Chapter 5 , you’ll learn how to change your page on command. This chapter will teach you how to alter the very structure an HTML document on the fly.

In Chapter 6 , you’ll learn how to make your site buzzword compliant. After reading this chapter, you, too, will be able to access server-side functionality without resorting to clunky page refreshes.

The third part of the book takes a different approach. Here you’ll work through several real-world examples, pulling together what you’ve learned in previous chapters and creating robust jQuery solutions to common problems. In Chapter 7 , you’ll sort, sift, and style information to create beautiful and functional data layouts.

In Chapter 8 , you’ll master the finer points of client-side validation, design an adaptive form layout, and implement interactive client-server form features such as auto-completion.

In Chapter 9 , you’ll enhance the beauty and utility of page elements by showing them in bite-size morsels. You’ll make information fly in and out of view both on its own and under user control.

In Chapter 10 you’ll learn about jQuery’s impressive extension capabilities. You’ll examine three prominent jQuery plug-ins and how to use them, and proceed to develop your own from the ground up.

Appendix A provides a handful of informative websites on a wide range of topics related to jQuery, JavaScript, and web development in general.

Appendix B recommends a number of useful third-party programs and utilities for editing and debugging jQuery code within your personal development environment.

Appendix C discusses one of the common stumbling blocks with the JavaScript language. You’ll come to rely on the power of closures, rather than fear their side effects.

Who This Book Is for

This book is for web designers who want to create interactive elements for their designs, and for developers who want to create the best user interface for their web applications.

The reader will need the basics of HTML and CSS, and should be comfortable with the syntax of JavaScript. No knowledge of jQuery is assumed, nor is experience with any other JavaScript libraries required.


In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

There are three styles for code. Code words in text are shown as follows: “Taken together, $() and .addClass() are enough for us to accomplish our goal of changing the appearance of the poem text.”

A block of code will be set as follows:

$(document).ready(function() {

When we wish to draw your attention to a particular part of a code block, the relevant lines or items will be made bold:

$(document).ready(function() {

New terms and important words are introduced in a bold-type font. Words that you see on the screen, in menus or dialog boxes for example, appear in our text like this: “The next step is to run those tests by clicking the All button.”


Important notes appear in a box like this.


Tips and tricks appear like this.

Reader Feedback

Feedback from our readers is always welcome. Let us know what you think about this book, what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply drop an email to , making sure to mention the book title in the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on or email .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on

Customer Support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the Example Code for the Book

Visit, and select this book from the list of titles to download any example code or extra resources for this book. The files available for download will then be displayed.

The downloadable files contain instructions on how to use them.


Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in text or code—we would be grateful if you would report this to us. By doing this you can save other readers from frustration, and help to improve subsequent versions of this book. If you find any errata, report them by visiting, selecting your book, clicking on the Submit Errata link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to the list of existing errata. The existing errata can be viewed by selecting your title from


You can contact us at if you are having a problem with some aspect of the book, and we will do our best to address it.