售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Learning jQuery Fourth Edition
Table of Contents
Learning jQuery Fourth Edition
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Getting Started
What jQuery does
Why jQuery works well
Making our first jQuery-powered web page
Downloading jQuery
Deciding on the version of jQuery to use
Setting up jQuery in an HTML document
Adding our jQuery code
Finding the poem text
Injecting the new class
Executing the code
The finished product
Plain JavaScript versus jQuery
Using development tools
Chrome Developer Tools
Summary
2. Selecting Elements
Understanding the DOM
Using the $() function
CSS selectors
Styling list-item levels
Attribute selectors
Styling links
Custom selectors
Styling alternate rows
Finding elements based on textual content
Form selectors
DOM traversal methods
Styling specific cells
Chaining
Accessing DOM elements
Summary
Further reading
Exercises
3. Handling Events
Performing tasks on page load
Timing of code execution
Handling multiple scripts on one page
Alternate syntax for .ready()
Passing an argument to the .ready() callback
Handling simple events
A simple style switcher
Enabling the other buttons
Making use of the event handler context
Consolidating code using the event context
Shorthand events
Showing and hiding advanced features
Event propagation
The journey of an event
Side effects of event bubbling
Altering the journey – the event object
Event targets
Stopping event propagation
Preventing default actions
Delegating events
Using built-in event-delegation capabilities
Removing an event handler
Giving namespaces to event handlers
Rebinding events
Simulating user interaction
Reacting to keyboard events
Summary
Further reading
Exercises
4. Styling and Animating
Modifying CSS with inline properties
Setting computed style-property values
Using vendor-specific style properties
Hiding and showing elements
Effects and duration
Speeding in
Fading in and fading out
Sliding up and sliding down
Toggling visibility
Creating custom animations
Building effects by hand
Animating multiple properties at once
Positioning with CSS
Simultaneous versus queued effects
Working with a single set of elements
Bypassing the queue
Queuing effects manually
Working with multiple sets of elements
Queuing with callbacks
In a nutshell
Summary
Further reading
Exercises
5. Manipulating the DOM
Manipulating attributes and properties
Non-class attributes
Value callbacks
DOM element properties
The value of form controls
DOM tree manipulation
The $() function revisited
Creating new elements
Inserting new elements
Moving elements
Wrapping elements
Explicit iteration
Using inverted insertion methods
Copying elements
Cloning for pull quotes
Content getter and setter methods
DOM manipulation methods in a nutshell
Summary
Further reading
Exercises
6. Sending Data with Ajax
Loading data on demand
Appending HTML
Working with JavaScript objects
Retrieving JSON
Using global jQuery functions
Executing a script
Loading an XML document
Choosing a data format
Passing data to the server
Performing a GET request
Performing a POST request
Serializing a form
Delivering different content for Ajax requests
Keeping an eye on the request
Error handling
Ajax and events
Security limitations
Using JSONP for remote data
Exploring additional options
The low-level Ajax method
Modifying default options
Loading parts of an HTML page
Summary
Further reading
Exercises
7. Using Plugins
Finding plugins and help
Using a plugin
Downloading and referencing the Cycle plugin
Calling a plugin method
Specifying plugin method parameters
Modifying parameter defaults
Other types of plugins
Custom selectors
Global function plugins
The jQuery UI plugin library
Effects
Color animations
Class animations
Advanced easing
Additional effects
Interaction components
Widgets
jQuery UI ThemeRoller
The jQuery Mobile plugin library
HTML5 custom data attributes
Mobile navigation
Delivering multiple pages in one document
Interactive elements
List views
Toolbar buttons
Advanced features
Summary
Exercises
8. Developing Plugins
Using the dollar ($) alias in plugins
Adding new global functions
Adding multiple functions
Extending the global jQuery object
Isolating functions within namespaces
Adding jQuery object methods
Object method context
Implicit iteration
Enabling method chaining
Providing flexible method parameters
The options object
Default parameter values
Callback functions
Customizable defaults
Creating plugins with the jQuery UI widget factory
Creating a widget
Destroying widgets
Enabling and disabling widgets
Accepting widget options
Adding submethods
Triggering widget events
Plugin design recommendations
Distributing a plugin
Summary
Exercises
9. Advanced Selectors and Traversing
Selecting and traversing revisited
Dynamic table filtering
Striping table rows
Combining filtering and striping
More selectors and traversal methods
Customizing and optimizing selectors
Writing a custom selector plugin
Selector performance
The Sizzle selector implementation
Testing selector speed
DOM traversal under the hood
jQuery object properties
The DOM element stack
Writing a DOM traversal method plugin
DOM traversal performance
Improving performance using chaining
Improving performance with caching
Summary
Further reading
Exercises
10. Advanced Events
Revisiting events
Loading additional pages of data
Displaying data on hovering
Event delegation
Using jQuery's delegation capabilities
Choosing a delegation scope
Delegating early
Defining custom events
Infinite scrolling
Custom event parameters
Throttling events
Other ways to perform throttling
Extending events
More about special events
Summary
Further reading
Exercises
11. Advanced Effects
Animation revisited
Observing and interrupting animations
Determining the animation state
Halting a running animation
Caution when halting animations
Using global effect properties
Disabling all effects
Defining effect durations
Multiproperty easing
Using deferred objects
Animation promises
Taking fine-grained control of animations
Summary
Further reading
Exercises
12. Advanced DOM Manipulation
Sorting table rows
Sorting tables on the server
Sorting tables using Ajax
Sorting tables within the browser
Moving and inserting elements revisited
Adding links around existing text
Sorting simple JavaScript arrays
Sorting DOM elements
Storing data alongside DOM elements
Performing additional precomputation
Storing non-string data
Alternating sort directions
Using HTML5 custom data attributes
Sorting and building rows with JSON
Modifying the JSON object
Rebuilding content on demand
Revisiting attribute manipulation
Using shorthand element-creation syntax
DOM manipulation hooks
Writing a CSS hook
Summary
Further reading
Exercises
13. Advanced Ajax
Implementing progressive enhancement with Ajax
Harvesting JSONP data
Handling Ajax errors
Using the jqXHR object
Ajax promises
Caching responses
Throttling Ajax requests
Extending Ajax capabilities
Data type converters
Adding Ajax prefilters
Defining alternate transports
Summary
Further reading
Exercises
A. JavaScript Closures
Creating inner functions
Calling inner functions from elsewhere
Understanding variable scope
Handling interactions between closures
Creating closures in jQuery
Passing arguments to $(document).ready()
Assigning event handlers
Binding handlers in loops
Giving names to functions
Handling memory-leak hazards
Avoiding accidental reference loops
Managing loops between the DOM and JavaScript
Disentangling reference loops with jQuery
Summary
B. Testing JavaScript with QUnit
Downloading QUnit
Setting up the document
Organizing tests
Adding and running tests
Asynchronous testing
Other types of tests
Practical considerations
Further reading
Summary
C. Quick Reference
Selector expressions
Simple CSS
Position among siblings
Position among matched elements
Attributes
Forms
Miscellaneous selectors
DOM traversal methods
Filtering
Descendants
Siblings
Ancestors
Collection manipulation
Working with selected elements
Event methods
Binding
Shorthand binding
Triggering
Shorthand triggering
Utility
Effect methods
Predefined effects
Custom animations
Queue manipulation
DOM manipulation methods
Attributes and properties
Content
CSS
Dimensions
Insertion
Replacement
Removal
Copying
Data
Ajax methods
Issuing requests
Request monitoring
Configuration
Utilities
Deferred objects
Object creation
Methods of deferred objects
Methods of promise objects
Miscellaneous properties and functions
Properties of the jQuery object
Arrays and objects
Object introspection
Other
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜