Synopses & Reviews
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
Synopsis
With the jQuery framework, you can create dynamic web pages without writing a line of JavaScript code, as long as you know which components to use and when. This pocket reference helps you quickly locate what you need from the jQuery library most useful for your web project. It's ideal for beginners and experienced JavaScript developers alike.
Along with a brief tutorial on the subject, jQuery Pocket Reference puts all of jQuery's features into one convenient place, including: How to insert, replace, wrap, and delete elements, attributes, and style information jQuery's cross-browser event model Animated visual effects Ajax utilities for making scripted HTTP requests The full syntax of jQuery's selectors, and how to use jQuery's advanced selection methods Extending jQuery by using and writing plugins The jQuery UI library
Synopsis
If you've turned to the jQuery library to simplify common client-side JavaScript tasks, this pocket reference will help you quickly locate what you need from jQuery's vast array of functions and properties to complete your web project. jQuery Pocket Reference provides a series of tutorials on getting and setting element content, methods for document modification, and more, along with a quick reference to the entire library. It's an ideal book for beginners and experienced JavaScript developers alike. With it, you'll learn:
- How to insert, replace, wrap, and delete elements, attributes, and style information
- jQuery's cross-browser event model
- Animated visual effects
- Ajax utilities for making scripted HTTP requests
- The full syntax of jQuery's selectors, and how to use jQuery's advanced selection methods
- Extending jQuery by using and writing plugins
- The jQuery UI library
Synopsis
"As someone who uses jQuery on a regular basis, it was surprising to discover how much of the library Im not using. This book is indispensable for anyone who is serious about using jQuery for non-trivial applications."-- Raffaele Cecco, longtime developer of video games, including Cybernoid, Exolon, and Stormlord
jQuery is the "write less, do more" JavaScript library. Its powerful features and ease of use have made it the most popular client-side JavaScript framework for the Web. Ideal for JavaScript developers at all skill levels, this book is jQuery's trusty companion: the definitive "read less, learn more" guide to the library.
jQuery Pocket Reference explains everything you need to know about jQuery, completely and comprehensively. You'll learn how to:
- Select and manipulate document elements
- Alter document structure
- Handle and trigger events
- Create visual effects and animations
- Script HTTP with Ajax utilities
- Use jQuery's selectors and selection methods, utilities, plugins and more
The 25-page quick reference summarizes the library, listing all jQuery methods and functions, with signatures and descriptions.
Synopsis
This book provides concrete details on how to build web interfaces with jQuery, the champion of the Ajax frameworks. jQuery rapidly climbed to prominence in the Ajax world, leaping forward in a crowded field. While much of that has to do with its power and relative ease of use, applying jQuery is still a challenge. "jQuery Cookbook" shows readers how to add jQuery to their web sites and applications, with recipe after recipe detailing tasks from basic integration to complex user interface development.
About the Author
David Flanagan is a JavaScript programmer at Mozilla. His books with OReilly include JavaScript: The Definitive Guide, jQuery Pocket Reference, The Ruby Programming Language, and Java in a Nutshell. David has a degree in computer science and engineering from the Massachusetts Institute of Technology. He lives with his wife and children in
Table of Contents
Foreword; Contributors; Chapter Authors; Tech Editors; Preface; Who This Book Is For; What Youll Learn; jQuery Style and Conventions; Other Options; If You Have Problems Making Examples Work; If You Like (or Dont 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 Dont 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 Thats Not jQuery, Its JavaScript!; 5.3 Whats 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 aaaaaa 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; Colophon;