jQuery Cookbook

jQuery Cookbook

by Cody Lindley (Editor)


$31.49 $34.99 Save 10% Current price is $31.49, Original price is $34.99. You Save 10%.
View All Available Formats & Editions
Choose Expedited Shipping at checkout for guaranteed delivery by Thursday, March 28

Product Details

ISBN-13: 9780596159771
Publisher: O'Reilly Media, Incorporated
Publication date: 12/03/2009
Series: Animal Guide Series
Pages: 451
Sales rank: 1,335,653
Product dimensions: 6.90(w) x 9.10(h) x 1.00(d)

About 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.

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;

Customer Reviews

Most Helpful Customer Reviews

See All Customer Reviews

JQuery Cookbook 2.9 out of 5 based on 0 ratings. 8 reviews.
George_A More than 1 year ago
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.
Ayp More than 1 year ago
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.
FactorThree More than 1 year ago
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.
greggT More than 1 year ago
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.
inquisitivedancer More than 1 year ago
I downloaded the sample to test this book out. It won't work therefore I won't buy it.
CraigNY More than 1 year ago
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.
Anonymous More than 1 year ago
Title says it all
Anonymous More than 1 year ago
Excellent Book