Home Page Icon
Home Page
Table of Contents for
Cover
Close
Cover
by David Sawyer McFarland
JavaScript & jQuery: The Missing Manual, 2nd Edition
A Note Regarding Supplemental Files
The Missing Credits
About the Author
About the Creative Team
Acknowledgements
The Missing Manual Series
Introduction
What Is JavaScript?
A Bit of History
JavaScript Is Everywhere
What Is jQuery?
HTML: The Barebones Structure
How HTML Tags Work
CSS: Adding Style to Web Pages
Anatomy of a Style
Software for JavaScript Programming
Free Programs
Commercial Software
About This Book
This Book’s Approach to JavaScript
About the Outline
The Very Basics
About→These→Arrows
About the Online Resources
Living Examples
Registration
Feedback
Errata
Safari® Books Online
One. Getting Started with JavaScript
1. Writing Your First JavaScript Program
Introducing Programming
What’s a Computer Program?
How to Add JavaScript to a Page
External JavaScript Files
Your First JavaScript Program
Writing Text on a Web Page
Attaching an External JavaScript File
Tracking Down Errors
The Firefox JavaScript Console
Displaying the Internet Explorer 9 Console
Opening the Chrome JavaScript Console
Accessing the Safari Error Console
2. The Grammar of JavaScript
Statements
Built-In Functions
Types of Data
Numbers
Strings
Booleans
Variables
Creating a Variable
Using Variables
Working with Data Types and Variables
Basic Math
The Order of Operations
Combining Strings
Combining Numbers and Strings
Changing the Values in Variables
Tutorial: Using Variables to Create Messages
Tutorial: Asking for Information
Arrays
Creating an Array
Accessing Items in an Array
Adding Items to an Array
Adding an item to the end of an array
Adding an item to the beginning of an array
Choosing how to add items to an array
Deleting Items from an Array
Tutorial: Writing to a Web Page Using Arrays
A Quick Object Lesson
Comments
When to Use Comments
Comments in This Book
3. Adding Logic and Control to Your Programs
Making Programs React Intelligently
Conditional Statement Basics
Adding a Backup Plan
Testing More Than One Condition
More Complex Conditions
Making sure more than one condition is true
Making sure at least one condition is true
Negating a condition
Nesting Conditional Statements
Tips for Writing Conditional Statements
Tutorial: Using Conditional Statements
Handling Repetitive Tasks with Loops
While Loops
Loops and Arrays
For Loops
Do/While Loops
Functions: Turn Useful Code Into Reusable Commands
Mini-Tutorial
Giving Information to Your Functions
Retrieving Information from Functions
Keeping Variables from Colliding
Tutorial: A Simple Quiz
Two. Getting Started with jQuery
4. Introducing jQuery
About JavaScript Libraries
Getting jQuery
Linking to the jQuery file on a CDN server
Linking to the jQuery file on a CDN server
Downloading your own jQuery file
Adding jQuery to a Page
Modifying Web Pages: An Overview
Understanding the Document Object Model
Selecting Page Elements: The jQuery Way
Basic Selectors
ID selectors
Element selectors
Class selectors
Advanced Selectors
jQuery Filters
Understanding jQuery Selections
Automatic loops
Chaining functions
Adding Content to a Page
Replacing and Removing Selections
Setting and Reading Tag Attributes
Classes
Reading and Changing CSS Properties
Changing Multiple CSS Properties at Once
Reading, Setting, and Removing HTML Attributes
Acting on Each Element in a Selection
Anonymous Functions
this and $(this)
Automatic Pull Quotes
Overview
Programming
5. Action/Reaction: Making Pages Come Alive with Events
What Are Events?
Mouse Events
Document/Window Events
Form Events
Keyboard Events
Using Events the jQuery Way
Tutorial: Introducing Events
More jQuery Event Concepts
Waiting for the HTML to Load
jQuery Events
The hover() event
The toggle() Event
The Event Object
Stopping an Event’s Normal Behavior
Removing Events
Advanced Event Management
Other Ways to Use the bind() Function
Tutorial: A One-Page FAQ
Overview of the Task
The Programming
6. Animations and Effects
jQuery Effects
Basic Showing and Hiding
Fading Elements In and Out
Sliding Elements
Tutorial: Login Slider
The Programming
Animations
Easing
Performing an Action After an Effect Is Completed
Tutorial: Animated Dashboard
The Programming
Three. Building Web Page Features
7. Improving Your Images
Swapping Images
Changing an Image’s src Attribute
Preloading Images
Rollover Images
Tutorial: Adding Rollover Images
Overview of the Task
The Programming
Tutorial: Photo Gallery with Effects
Overview of Task
The Programming
Advanced Gallery with jQuery FancyBox
The Basics
Creating a Gallery of Images
Customizing FancyBox
FancyBox options
Styling FancyBox
Tutorial: FancyBox Photo Gallery
8. Improving Navigation
Some Link Basics
Selecting Links with JavaScript
Determining a Link’s Destination
Don’t Follow That Link
Opening External Links in a New Window
Creating New Windows
Window Properties
Use the window reference
Events that can open a new window
Opening Pages in a Window on the Page
Tutorial: Opening a Page Within a Page
Basic, Animated Navigation Bar
The HTML
The CSS
The JavaScript
The Tutorial
9. Enhancing Web Forms
Understanding Forms
Selecting Form Elements
Getting and Setting the Value of a Form Element
Determining Whether Buttons and Boxes Are Checked
Form Events
Submit
Focus
Blur
Click
Change
Adding Smarts to Your Forms
Focusing the First Field in a Form
Disabling and Enabling Fields
Hiding and Showing Form Options
Tutorial: Basic Form Enhancements
Focusing a Field
Disabling Form Fields
Hiding Form Fields
Form Validation
jQuery Validation Plug-in
Basic Validation
Adding validation rules
Adding error messages
Advanced Validation
Advanced rules
Advanced error messages
Styling Error Messages
Validation Tutorial
Basic Validation
Advanced Validation
Validating Checkboxes and Radio Buttons
Formatting the Error Messages
10. Expanding Your Interface
Organizing Information in Tabbed Panels
The HTML
The CSS
The JavaScript
Tabbed Panels Tutorial
Adding a Content Slider to Your Site
Using AnythingSlider
AnythingSlider Tutorial
Customizing the Slider Appearance
Customizing the Slider Behavior
Determining the Size and Position of Page Elements
Determining the Height and Width of Elements
Determining the Position of Elements on a Page
Determining a Page’s Scrolling Position
Adding Tooltips
The HTML
The CSS
The JavaScript
Tooltips Tutorial
Four. Ajax: Communication with the Web Server
11. Introducing Ajax
What Is Ajax?
Ajax: The Basics
Pieces of the Puzzle
Talking to the Web Server
Ajax the jQuery Way
Using the load() Function
Tutorial: The load() Function
Overview
The programming
The get() and post() Functions
Formatting Data to Send to the Server
Query string
Object literal
jQuery’s serialize() function
Processing Data from the Server
Handling Errors
Tutorial: Using the get() Function
Overview
The programming
JSON
Accessing JSON Data
Complex JSON Objects
12. Flickr and Google Maps
Introducing JSONP
Adding a Flickr Feed to Your Site
Constructing the URL
A few other options for the public photos feed
Using the $.getJSON() Function
Understanding the Flickr JSON Feed
Tutorial: Adding Flickr Images to Your Site
Adding Google Maps to Your Site
Setting a Location for the Map
Other GoMap Options
Adding Markers
Adding Information Windows to Markers
GoMap Tutorial
Five. Tips, Tricks, and Troubleshooting
13. Getting the Most from jQuery
Useful jQuery Tips and Information
$() Is the Same as jQuery()
Saving Selections Into Variables
Adding Content as Few Times as Possible
Optimizing Your Selectors
Using the jQuery Docs
Reading a Page on the jQuery Docs Site
Traversing the DOM
More Functions For Manipulating HTML
Advanced Event Handling
14. Going Further with JavaScript
Working with Strings
Determining the Length of a String
Changing the Case of a String
Searching a String: indexOf() Technique
Extracting Part of a String with slice()
Finding Patterns in Strings
Creating and Using a Basic Regular Expression
Building a Regular Expression
Grouping Parts of a Pattern
Useful Regular Expressions
U.S. Zip code
U.S. phone number
Email address
Date
Web address
Matching a Pattern
Matching every instance of a pattern
Replacing Text
Trying Out Regular Expressions
Working with Numbers
Changing a String to a Number
Testing for Numbers
Rounding Numbers
Formatting Currency Values
Creating a Random Number
Randomly selecting an array element
A function for selecting a random number
Dates and Times
Getting the Month
Getting the Day of the Week
Getting the Time
Changing hours to a.m. and p.m.
Padding single digits
Creating a Date Other Than Today
Creating a date that’s one week from today
Putting It All Together
Using External JavaScript Files
Writing More Efficient JavaScript
Putting Preferences in Variables
Ternary Operator
The Switch Statement
Creating Fast-Loading JavaScript
15. Troubleshooting and Debugging
Top JavaScript Programming Mistakes
Non-Closed Pairs
Quotation Marks
Using Reserved Words
Single Equals in Conditional Statements
Case-Sensitivity
Incorrect Path to External JavaScript File
Incorrect Paths Within External JavaScript Files
Disappearing Variables and Functions
Debugging with Firebug
Installing and Turning On Firebug
Viewing Errors with Firebug
Using console.log() to Track Script Progress
Tutorial: Using the Firebug Console
More Powerful Debugging
Controlling your script with the debugger
Watching your script
Debugging Tutorial
A. JavaScript Resources
References
Websites
Books
Basic JavaScript
Articles and Presentations
Websites
Books
jQuery
Articles and Presentations
Websites
Books
Ajax
Websites
Books
Advanced JavaScript
Articles and Presentations
Websites
Books
CSS
Websites
Books
Index
About the Author
Colophon
Copyright
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Next
Next Chapter
JavaScript & jQuery: The Missing Manual, Second Edition
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset