Practical jQuery

Book description

Practical jQuery is your step-by-step guide to using jQuery in the real world, taking you from downloading jQuery all the way to extending it by writing your own plug-ins and testing the DOM using QUnit. jQuery is one of today’s most popular JavaScript web application development frameworks and libraries. While getting started with the tool is easy, sometimes it's not as simple to completely realize the power and automation that it can bring to your development work—and that's especially the case when you're in the middle of a project, up against a deadline.

Using this book, you will learn how to use jQuery’s powerful DOM manipulation tools to dynamically update content on your site. You will be able to extend jQuery’s capabilities by writing your own plugins on top of the framework, animate elements, build your own jQuery elements, employ best practices, and avoid common errors. Practical jQuery teaches you how, with jQuery, you can unit test and refactor your code. You’ll see how expressive yet concise jQuery’s code is and how much quicker and efficient it is to develop with jQuery.

Get a fundamental perspective on how jQuery works, how to understand, select, and build your own plug-ins, and how to make sure your projects run at the peak of their potential performance using Practical jQuery today.

Table of contents

  1. Cover
  2. Title
  3. Copyright
  4. Dedication
  5. Contents at a Glance
  6. Contents
  7. About the Authors
  8. About the Technical Reviewer
  9. Acknowledgments
  10. Introduction
  11. Chapter 1: Evolution of jQuery
    1. Traditional JavaScript Basics
      1. The Window Object
      2. Child Objects
    2. Old School Challenges
      1. Challenges Pertaining to the Window Object
      2. Challenges Pertaining to the Document Object
      3. Challenges Related to the Globals
    3. Need for a Revolution
    4. Who Was the Revolutionary?
    5. Why jQuery?
      1. Minimal and Easy Coding
      2. Readable/Clean Code
      3. Easy CSS Handling
      4. Animation Methods
      5. Intuitive Function Calls
    6. Summary
  12. Chapter 2: Getting Started with jQuery
    1. Document Object Model (DOM)
    2. Downloading and Setting Up jQuery
      1. Downloading from the Official Web Site
      2. Including jQuery from a CDN
      3. Clone from GitHub
    3. jQuery Fundamentals
      1. jQuery Syntax
      2. Document Ready Event
      3. jQuery noConflict() Method
      4. jQuery Selectors
    4. Working with jQuery
      1. The Problem Statement
      2. The Anonymous Function
      3. Preloading Images with jQuery
      4. each() in jQuery
    5. Summary
  13. Chapter 3: Traversing DOM with jQuery
    1. Selecting Elements with CSS Selectors
      1. Type Selector
      2. Universal Selector
      3. Attribute Selector
      4. Class Selector
      5. ID Selector
      6. Pseudo Class Selector
      7. Relationship-Based Selectors
    2. Using jQuery Selectors
      1. Type Selector
      2. Universal Selector
      3. Attribute Selector
      4. Class Selector
      5. ID Selector
      6. Pseudo Class Selector
      7. Other jQuery Selectors
    3. Traversing DOM with jQuery Traversal MethodsTraversal methods
      1. The Curtain Raiser
      2. jQuery Methods for DOM Traversal
    4. Caching Selector and Chaining Methods
      1. Selector Caching
      2. Chaining
    5. jQuery Filtering
      1. The .eq() Method
      2. The .filter() Method
      3. The .first() Method
      4. The .last() Method
      5. The .has() Method
      6. The .is() Method
      7. The .not() Method
    6. Summary
  14. Chapter 4: DOM Manipulation with jQuery
    1. Editing Appearance with jQuery CSS Methods
      1. Obtaining CSS Properties
      2. Setting CSS Properties
      3. Setting Multiple CSS Properties
    2. Editing/Changing an Element’s Attributes, Contents, and Position
      1. Editing Attributes
      2. Editing Contents
    3. Creating and Inserting New DOM Elements
      1. .append(?) vs. .appendTo(?)
      2. Inserting New Elements in Specific Locations
      3. Putting the Methods to Work
    4. Removing and Cloning DOM Elements
    5. Working with Dimensions
      1. jQuery width(?) and height(?) Methods
      2. jQuery innerWidth(?) and innerHeight(?) Methods
      3. jQuery .outerWidth(?) and .outerHeight(?) Methods
    6. Summary
  15. Chapter 5: Events in jQuery
    1. Introducing Events
    2. Browsers and Events
    3. Event Listeners and Event Handlers
    4. The Event( ) Method in jQuery
      1. Binding Events
      2. Unbinding Events
    5. Events Propagation and Events Bubbling
      1. The Event Capturing and Event Bubbling Models
      2. The W3C Event Model
    6. Callback Action in Event
    7. Summary
  16. Chapter 6: Real World Events in jQuery
    1. Common Gotchas in Event Handling
      1. Handling Dynamic Elements
      2. Handling jQuery Animation Buildup
    2. Preventing Event Propagation and Bubbling
    3. Handling the Event Queue
      1. How Handling Works in a jQuery Event Queue
      2. The jQuery queue( ) Method
    4. Building a jQuery UI Accordion
      1. Using the jQuery UI Accordion
      2. Customizing an Accordion
    5. Validating Form Elements
      1. Using the Validate Plug-in
      2. Validating Form Elements Using Customized jQuery
    6. Summary
  17. Chapter 7: Animation in jQuery
    1. Life Without jQuery
    2. jQuery’s animate( )
    3. Fading in jQuery
      1. Using the fadeOut( ) Method
      2. Using the fadeIn( ) Method
      3. Using the fadeTo( ) Method
      4. Using the fadeToggle( ) Method
    4. Sliding in jQuery
      1. Using the slideUp( ) Method
      2. Using the slideDown( ) Method
      3. Using the slideToggle( ) Method
    5. Toggle( ) in jQuery
    6. Creating a Basic Light Box
    7. Controlling Animation Behavior
      1. Smoothing Your Animations
      2. Using the fx Object to Control Frame Rate
      3. Turning Off Your Animation
    8. Creating a Basic Image Slider
    9. Summary
  18. Chapter 8: Ajax with jQuery
    1. Introducing Ajax
      1. How Did Ajax Originate?
      2. The Technologies That Make Up Ajax
    2. Ajax Using jQuery
      1. The Nuts and Bolts of Ajax in JavaScript
      2. The jQuery Approach
    3. Introducing JSON
      1. Understanding JSON
      2. Parsing JSON with JavaScript
      3. Using the jQuery Alternative to JavaScript
    4. Ajax and JSON Usage Example
    5. Summary
  19. Chapter 9: Creating Plug-ins with jQuery
    1. What Is a Plug-in?
    2. Plug-in Best Practices
      1. Private Variables
      2. Public Variables
      3. Parameters
    3. Plug-in Writing Guidelines
      1. Do You Really Need the Plug-in?
      2. Reuse What Already Exists
      3. Preserve the Reference to jQuery
      4. Do Not Unnecessarily Modify Objects
      5. Ensure Chainability
    4. Creating a Form Validation Plug-in
    5. Creating an Accordion Plug-in
    6. Summary
  20. Chapter 10: Integrating Plug-ins with jQuery
    1. Plug-in Repositories
      1. The jQuery Registry
      2. The NPM Open Source Package Repository
      3. The GitHub Repository
    2. Integrating Plug-ins
      1. Downloading and Saving
      2. Do a Test Run on Some Simple Elements
      3. Include the Plug-in File in the script Tag
      4. The Dilemma—in the Head or at the End of the Body
      5. Keep the Code Clean
    3. Plug-in Customization
    4. Minifying Code for Distribution
      1. Compression vs. Minification
      2. What Does Minified Code Look Like?
      3. There Is More: Uglification and Beautification
    5. Summary
  21. Chapter 11: Using jQuery Frameworks
    1. JavaScript and jQuery Frameworks
      1. Bootstrap
      2. AngularJS
    2. Components in jQuery
    3. jQuery UI
      1. Drag and Drop Using jQuery UI
      2. Autocomplete
      3. Datepicker
    4. jQuery Mobile
      1. Some Cool Features of jQuery Mobile
      2. Ajax Navigation System
      3. Pop-ups in jQuery Mobile
    5. Summary
  22. Chapter 12: Testing jQuery with QUnit
    1. QUnit as a JavaScript Framework
    2. Introduction to Unit Testing
      1. The Need for Unit Testing
      2. Why QUnit?
    3. Getting Started with QUnit
      1. QUnit Syntax
      2. Styling the Test Result
      3. Writing the First Test Case
      4. Commonly Used QUnit Methods
    4. Testing DOM Manipulation
    5. Refactoring Code
      1. A Simple Refactoring
      2. Moving Ahead in Refactoring
      3. Writing Another Test Case on the Refactored Code
    6. Summary
  23. Index

Product information

  • Title: Practical jQuery
  • Author(s): Mukund Chaudhary, Ankur Kumar
  • Release date: July 2015
  • Publisher(s): Apress
  • ISBN: 9781484207871