jQuery Cookbook [NOOK Book]


jQuery simplifies building rich, interactive web frontends. Getting started with this JavaScript library is easy, but it can take years to fully realize its breadth and depth; this cookbook shortens the learning curve considerably. With these recipes, you'll learn patterns and practices from 19 leading developers who use jQuery for everything from integrating simple components into websites and applications ...

See more details below
jQuery Cookbook

Available on NOOK devices and apps  
  • NOOK Devices
  • NOOK HD/HD+ Tablet
  • NOOK
  • NOOK Color
  • NOOK Tablet
  • Tablet/Phone
  • NOOK for Windows 8 Tablet
  • NOOK for iOS
  • NOOK for Android
  • NOOK Kids for iPad
  • PC/Mac
  • NOOK for Windows 8
  • NOOK for PC
  • NOOK for Mac
  • NOOK Study
  • NOOK for Web

Want a NOOK? Explore Now

NOOK Book (eBook)
BN.com price
(Save 44%)$27.99 List Price


jQuery simplifies building rich, interactive web frontends. Getting started with this JavaScript library is easy, but it can take years to fully realize its breadth and depth; this cookbook shortens the learning curve considerably. With these recipes, you'll learn patterns and practices from 19 leading developers who use jQuery for everything from integrating simple components into websites and applications to developing complex, high-performance user interfaces.

Ideal for newcomers and JavaScript veterans alike, jQuery Cookbook starts with the basics and then moves to practical use cases with tested solutions to common web development hurdles. You also get recipes on advanced topics, such as methods for applying jQuery to large projects.

  • Solve problems involving events, effects, dimensions, forms, themes, and user interface elements
  • Learn how to enhance your forms, and how to position and reposition elements on a page
  • Make the most of jQuery's event management system, including custom events and custom event data
  • Create UI elements-such as tabs, accordions, and modals-from scratch
  • Optimize your code to eliminate bottlenecks and ensure peak performance
  • Learn how to test your jQuery applications

The book's contributors include:

  • Cody Lindley
  • James Padolsey
  • Ralph Whitbeck
  • Jonathan Sharp
  • Michael Geary and Scott González
  • Rebecca Murphey
  • Remy Sharp
  • Ariel Flesler
  • Brian Cherne
  • Jörn Zaefferer
  • Mike Hostetler
  • Nathan Smith
  • Richard D. Worth
  • Maggie Wachs, Scott Jehl, Todd Parker, and Patty Toland
  • Rob Burns
Read More Show Less

Product Details

  • ISBN-13: 9781449383015
  • Publisher: O'Reilly Media, Incorporated
  • Publication date: 1/25/2010
  • Series: Animal Guide
  • Sold by: Barnes & Noble
  • Format: eBook
  • Edition number: 1
  • Pages: 480
  • Sales rank: 681,248
  • File size: 5 MB

Meet the Author

Cody Lindley, editor of jQuery Cookbook, brings together over a dozen contributors, all of them key people in jQuery's ongoing development process. Each focuses on subjects they've worked with and often helped create.

Read More Show Less

Table of Contents

Chapter Authors;
Tech Editors;
Who This Book Is For;
What You’ll Learn;
jQuery Style and Conventions;
Other Options;
If You Have Problems Making Examples Work;
If You Like (or Don’t Like) This Book;
Conventions Used in This Book;
Using Code Examples;
Safari® Books Online;
How to Contact Us;
Chapter 1: jQuery Basics;
1.1 Introduction;
1.2 Including the jQuery Library Code in an HTML Page;
1.3 Executing jQuery/JavaScript Coded After the DOM Has Loaded but Before Complete Page Load;
1.4 Selecting DOM Elements Using Selectors and the jQuery Function;
1.5 Selecting DOM Elements Within a Specified Context;
1.6 Filtering a Wrapper Set of DOM Elements;
1.7 Finding Descendant Elements Within the Currently Selected Wrapper Set;
1.8 Returning to the Prior Selection Before a Destructive Change;
1.9 Including the Previous Selection with the Current Selection;
1.10 Traversing the DOM Based on Your Current Context to Acquire a New Set of DOM Elements;
1.11 Creating, Operating on, and Inserting DOM Elements;
1.12 Removing DOM Elements;
1.13 Replacing DOM Elements;
1.14 Cloning DOM Elements;
1.15 Getting, Setting, and Removing DOM Element Attributes;
1.16 Getting and Setting HTML Content;
1.17 Getting and Setting Text Content;
1.18 Using the $ Alias Without Creating Global Conflicts;
Chapter 2: Selecting Elements with jQuery;
2.1 Introduction;
2.2 Selecting Child Elements Only;
2.3 Selecting Specific Siblings;
2.4 Selecting Elements by Index Order;
2.5 Selecting Elements That Are Currently Animating;
2.6 Selecting Elements Based on What They Contain;
2.7 Selecting Elements by What They Don’t Match;
2.8 Selecting Elements Based on Their Visibility;
2.9 Selecting Elements Based on Attributes;
2.10 Selecting Form Elements by Type;
2.11 Selecting an Element with Specific Characteristics;
2.12 Using the Context Parameter;
2.13 Creating a Custom Filter Selector;
Chapter 3: Beyond the Basics;
3.1 Introduction;
3.2 Looping Through a Set of Selected Results;
3.3 Reducing the Selection Set to a Specified Item;
3.4 Convert a Selected jQuery Object into a Raw DOM Object;
3.5 Getting the Index of an Item in a Selection;
3.6 Making a Unique Array of Values from an Existing Array;
3.7 Performing an Action on a Subset of the Selected Set;
3.8 Configuring jQuery Not to Conflict with Other Libraries;
3.9 Adding Functionality with Plugins;
3.10 Determining the Exact Query That Was Used;
Chapter 4: jQuery Utilities;
4.1 Introduction;
4.2 Detecting Features with jQuery.support;
4.3 Iterating Over Arrays and Objects with jQuery.each;
4.4 Filtering Arrays with jQuery.grep;
4.5 Iterating and Modifying Array Entries with jQuery.map;
4.6 Combining Two Arrays with jQuery.merge;
4.7 Filtering Out Duplicate Array Entries with jQuery.unique;
4.8 Testing Callback Functions with jQuery.isFunction;
4.9 Removing Whitespace from Strings or Form Values with jQuery.trim;
4.10 Attaching Objects and Data to DOM with jQuery.data;
4.11 Extending Objects with jQuery.extend;
Chapter 5: Faster, Simpler, More Fun;
5.1 Introduction;
5.2 That’s Not jQuery, It’s JavaScript!;
5.3 What’s Wrong with $(this)?;
5.4 Removing Redundant Repetition;
5.5 Formatting Your jQuery Chains;
5.6 Borrowing Code from Other Libraries;
5.7 Writing a Custom Iterator;
5.8 Toggling an Attribute;
5.9 Finding the Bottlenecks;
5.10 Caching Your jQuery Objects;
5.11 Writing Faster Selectors;
5.12 Loading Tables Faster;
5.13 Coding Bare-Metal Loops;
5.14 Reducing Name Lookups;
5.15 Updating the DOM Faster with .innerHTML;
5.16 Debugging? Break Those Chains;
5.17 Is It a jQuery Bug?;
5.18 Tracing into jQuery;
5.19 Making Fewer Server Requests;
5.20 Writing Unobtrusive JavaScript;
5.21 Using jQuery for Progressive Enhancement;
5.22 Making Your Pages Accessible;
Chapter 6: Dimensions;
6.1 Introduction;
6.2 Finding the Dimensions of the Window and Document;
6.3 Finding the Dimensions of an Element;
6.4 Finding the Offset of an Element;
6.5 Scrolling an Element into View;
6.6 Determining Whether an Element Is Within the Viewport;
6.7 Centering an Element Within the Viewport;
6.8 Absolutely Positioning an Element at Its Current Position;
6.9 Positioning an Element Relative to Another Element;
6.10 Switching Stylesheets Based on Browser Width;
Chapter 7: Effects;
7.1 Introduction;
7.2 Sliding and Fading Elements in and out of View;
7.3 Making Elements Visible by Sliding Them Up;
7.4 Creating a Horizontal Accordion;
7.5 Simultaneously Sliding and Fading Elements;
7.6 Applying Sequential Effects;
7.7 Determining Whether Elements Are Currently Being Animated;
7.8 Stopping and Resetting Animations;
7.9 Using Custom Easing Methods for Effects;
7.10 Disabling All Effects;
7.11 Using jQuery UI for Advanced Effects;
Chapter 8: Events;
8.1 Introduction;
8.2 Attaching a Handler to Many Events;
8.3 Reusing a Handler Function with Different Data;
8.4 Removing a Whole Set of Event Handlers;
8.5 Triggering Specific Event Handlers;
8.6 Passing Dynamic Data to Event Handlers;
8.7 Accessing an Element ASAP (Before document.ready);
8.8 Stopping the Handler Execution Loop;
8.9 Getting the Correct Element When Using event.target;
8.10 Avoid Multiple hover() Animations in Parallel;
8.11 Making Event Handlers Work for Newly Added Elements;
Chapter 9: Advanced Events;
9.1 Introduction;
9.2 Getting jQuery to Work When Loaded Dynamically;
9.3 Speeding Up Global Event Triggering;
9.4 Creating Your Own Events;
9.5 Letting Event Handlers Provide Needed Data;
9.6 Creating Event-Driven Plugins;
9.7 Getting Notified When jQuery Methods Are Called;
9.8 Using Objects’ Methods as Event Listeners;
Chapter 10: HTML Form Enhancements from Scratch;
10.1 Introduction;
10.2 Focusing a Text Input on Page Load;
10.3 Disabling and Enabling Form Elements;
10.4 Selecting Radio Buttons Automatically;
10.5 (De)selecting All Checkboxes Using Dedicated Links;
10.6 (De)selecting All Checkboxes Using a Single Toggle;
10.7 Adding and Removing Select Options;
10.8 Autotabbing Based on Character Count;
10.9 Displaying Remaining Character Count;
10.10 Constraining Text Input to Specific Characters;
10.11 Submitting a Form Using Ajax;
10.12 Validating Forms;
Chapter 11: HTML Form Enhancements with Plugins;
11.1 Introduction;
11.2 Validating Forms;
11.3 Creating Masked Input Fields;
11.4 Autocompleting Text Fields;
11.5 Selecting a Range of Values;
11.6 Entering a Range-Constrained Value;
11.7 Uploading Files in the Background;
11.8 Limiting the Length of Text Inputs;
11.9 Displaying Labels Above Input Fields;
11.10 Growing an Input with Its Content;
11.11 Choosing a Date;
Chapter 12: jQuery Plugins;
12.1 Introduction;
12.2 Where Do You Find jQuery Plugins?;
12.3 When Should You Write a jQuery Plugin?;
12.4 Writing Your First jQuery Plugin;
12.5 Passing Options into Your Plugin;
12.6 Using the $ Shortcut in Your Plugin;
12.7 Including Private Functions in Your Plugin;
12.8 Supporting the Metadata Plugin;
12.9 Adding a Static Function to Your Plugin;
12.10 Unit Testing Your Plugin with QUnit;
Chapter 13: Interface Components from Scratch;
13.1 Introduction;
13.2 Creating Custom Tool Tips;
13.3 Navigating with a File-Tree Expander;
13.4 Expanding an Accordion;
13.5 Tabbing Through a Document;
13.6 Displaying a Simple Modal Window;
13.7 Building Drop-Down Menus;
13.8 Cross-Fading Rotating Images;
13.9 Sliding Panels;
Chapter 14: User Interfaces with jQuery UI;
14.1 Introduction;
14.2 Including the Entire jQuery UI Suite;
14.3 Including an Individual jQuery UI Plugin or Two;
14.4 Initializing a jQuery UI Plugin with Default Options;
14.5 Initializing a jQuery UI Plugin with Custom Options;
14.6 Creating Your Very Own jQuery UI Plugin Defaults;
14.7 Getting and Setting jQuery UI Plugin Options;
14.8 Calling jQuery UI Plugin Methods;
14.9 Handling jQuery UI Plugin Events;
14.10 Destroying a jQuery UI Plugin;
14.11 Creating a jQuery UI Music Player;
Chapter 15: jQuery UI Theming;
15.1 Introduction;
15.2 Styling jQuery UI Widgets with ThemeRoller;
15.3 Overriding jQuery UI Layout and Theme Styles;
15.4 Applying a Theme to Non-jQuery UI Components;
15.5 Referencing Multiple Themes on a Single Page;
15.6 Appendix: Additional CSS Resources;
Chapter 16: jQuery, Ajax, Data Formats: HTML, XML, JSON, JSONP;
16.1 Introduction;
16.2 jQuery and Ajax;
16.3 Using Ajax on Your Whole Site;
16.4 Using Simple Ajax with User Feedback;
16.5 Using Ajax Shortcuts and Data Types;
16.6 Using HTML Fragments and jQuery;
16.7 Converting XML to DOM;
16.8 Creating JSON;
16.9 Parsing JSON;
16.10 Using jQuery and JSONP;
Chapter 17: Using jQuery in Large Projects;
17.1 Introduction;
17.2 Using Client-Side Storage;
17.3 Saving Application State for a Single Session;
17.4 Saving Application State Between Sessions;
17.5 Using a JavaScript Template Engine;
17.6 Queuing Ajax Requests;
17.7 Dealing with Ajax and the Back Button;
17.8 Putting JavaScript at the End of a Page;
Chapter 18: Unit Testing;
18.1 Introduction;
18.2 Automating Unit Testing;
18.3 Asserting Results;
18.4 Testing Synchronous Callbacks;
18.5 Testing Asynchronous Callbacks;
18.6 Testing User Actions;
18.7 Keeping Tests Atomic;
18.8 Grouping Tests;
18.9 Selecting Tests to Run;

Read More Show Less

Customer Reviews

Average Rating 3
( 8 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing all of 8 Customer Reviews
  • Posted January 2, 2010

    Full of "recipes"

    This book is full of jQuery "recipes", by recipes the author is supplying a set short problems, solutions, and discussions covering a concept. Most of the recipes are between one and two pages and cover a wide variety of jQuery. Although I read this book cover to cover, it is probably better as a reference tool. It starts out with simple examples and progresses into more advanced examples. Still this book appears to be aimed more at the beginner to intermediate. Having very little jQuery experience I found the book quite easy to follow and examples easy to understand.

    Although the book is mostly examples, it does address some interesting concepts, such as the concept of putting your JavaScript at the end of the page to enhance performance.

    I like to type code when studying a book, but all the examples are on the web and can be viewed without writing any code. You can also do a "view page" and copy all the code to be modified if you want to use it. I don't normally give five stars for books, but I did for this one. I find it very useful and keep it on the desk for easy reference. Even an advanced person might find a few gems in it, which they could find useful.

    2 out of 2 people found this review helpful.

    Was this review helpful? Yes  No   Report this review
  • Posted December 22, 2010

    WARNING! Broken book

    I have made several attempts to download a sample of this book. When I attempt to open it, I get a message saying it cannot be opened.

    I know that the downloads are corrupt; I loaded it on my Nook Color and on the Nook reader for the PC. This file cannot be opened.

    Worse, I made several attempts to report this problem to B&N Customer Service, only to be hand- held through repeated download attempts (as if I somehow didn't know how to download!). The file or the system used for this book is obviously corrupted, yet my repeated attempts to explain this to the Customer Service personnel have failed.

    Until B&N finally figures out that there is a problem here and fixes it, I'd advise getting the print version of this book.

    1 out of 2 people found this review helpful.

    Was this review helpful? Yes  No   Report this review
  • Posted September 1, 2010

    NOT suitable for reading on Mac

    Although the content of this book is clear and well-suited to both beginners and experts -- because it assumes nothing and proceeds at a good pace -- it is NOT displaying properly on a Mac Nook client. This info is deeply buried in the B&N purchasing webpages, and I did not see it when deciding to buy it.

    Buy the paper copy, or use a non-Mac, non-Blackberry client to read it.
    Shame on B&N for burying the most important part of my buying decision and also writing a half-baked clients.

    BTW, as of this writing (Sep 2010), there STILL is no Kindle version of this book.

    1 out of 2 people found this review helpful.

    Was this review helpful? Yes  No   Report this review
  • Posted August 2, 2011

    Sample Won't Work

    I downloaded the sample to test this book out. It won't work therefore I won't buy it.

    0 out of 1 people found this review helpful.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted June 9, 2011

    As of 6/9/2011 sample still does not open

    Title says it all

    0 out of 2 people found this review helpful.

    Was this review helpful? Yes  No   Report this review
  • Posted May 9, 2011

    more from this reviewer

    Nice book

    I would recommend this book to anyone who wants to learn jQuery. This book consists of receipes which are stand alone examples followed by details on how it works. It also provides information on what to avoid, how to do something more efficient and is oriented towards good performance so that your pages load pretty fast. Each chapter is written by a separate author on a specific jQuery topics with external reference links as needed. The book is oriented more towards the intermediate or advanced users - though begineers should not have much trouble picking it up. The examples are well written and the explanation is good. The code which needs to be focused on is highlighted in bold so that it gets your attention. This book can also be used as a reference though not as a pocket reference. Overall I recommend this book to anyone who wants to learn jQuery.

    Was this review helpful? Yes  No   Report this review
  • Posted January 21, 2011

    It's true -- sample doesn't work

    I thought I'd try downloading the sample (assuming it had surely been fixed by now), but it hasn't. My nook cannot open it. I'm tempted by the book but won't take a chance on its not working.

    0 out of 1 people found this review helpful.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted December 1, 2009

    Excellent Book

    Excellent Book

    0 out of 3 people found this review helpful.

    Was this review helpful? Yes  No   Report this review
Sort by: Showing all of 8 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)