jQuery 1.4 Reference Guide
By Jonathan Chaffer and Karl Swedberg
3.5/5
()
About this ebook
To make optimal use of jQuery, it's good to keep in mind the breadth of capabilities it provides. You can add dynamic, interactive elements to your sites with reduced development time using jQuery.
Revised and updated for version 1.4 of jQuery, this book offers an organized menu of every jQuery method, function, and selector. Each method and function is introduced with a summary of its syntax and a list of its parameters and return value, followed by a discussion, with examples where applicable, to assist in getting the most out of jQuery and avoiding the pitfalls commonly associated with JavaScript and other client-side languages.
In this book you will be provided information about the latest features of jQuery that include Sizzle Selector, Native event delegation, Event triggering, DOM manipulation, and many more. You won't be confined to built-in functionality, you'll be able to examine jQuery's plug-in architecture and we discuss both how to use plug-ins and how to write your own. If you're already familiar with JavaScript programming, this book will help you dive right into advanced jQuery concepts. You'll be able to experiment on your own, trusting the pages of this book to provide information on the intricacies of the library, where and when you need it.
This book is a companion to Learning jQuery 1.3. Learning jQuery 1.3 begins with a tutorial to jQuery, where the authors share their knowledge, experience, and enthusiasm about jQuery to help you get the most from the library and to make your web applications shine.
jQuery 1.4 Reference Guide digs deeper into the library, taking you through the syntax specifications and following up with detailed discussions. You'll discover the untapped possibilities that jQuery 1.4 makes available, and polish your skills as you return to this guide time and again.
Learn from the expertsIn this book and eBook, the creators of the popular jQuery learning resource, learningquery.com, share their knowledge, experience, and enthusiasm to bring you a comprehensive reference to this popular JavaScript library.
ApproachThe book is a detailed reference guide, and an invaluable resource for answers to all your queries about jQuery. It is intended to be a quick reference to help at times when you need to quickly confirm a feature of the library
Who this book is forThis book is for you if you are a web developer who wants a broad, organized view of all that jQuery library has to offer or a quick reference on their desk to refer to for particular details. Basic knowledge of HTML and CSS is required. You should be comfortable with the syntax of JavaScript, but no knowledge of jQuery is assumed.
This is a reference guide, not an introductory title and if you are looking to get started with jQuery (or JavaScript libraries in general) then you are looking for the companion title Learning jQuery 1.3.
Jonathan Chaffer
Jonathan Chaffer is a member of Rapid Development Group, a web development firm located in Grand Rapids, Michigan. His work there includes overseeing and implementing projects in a wide variety of technologies, with an emphasis in PHP, MySQL, and JavaScript. He also leads on-site training seminars on the jQuery framework for web developers. In the open-source community, Jonathan has been very active in the Drupal CMS project, which has adopted jQuery as its JavaScript framework of choice. He is the creator of the Content Construction Kit, a popular module for managing structured content on Drupal sites. He is responsible for major overhauls of Drupal's menu system and developer API reference. Jonathan lives in Grand Rapids with his wife, Jennifer.
Read more from Jonathan Chaffer
Learning jQuery 3 - Fifth Edition Rating: 0 out of 5 stars0 ratingsLearning jQuery Rating: 4 out of 5 stars4/5
Related to jQuery 1.4 Reference Guide
Related ebooks
Advanced C Concepts and Programming: First Edition Rating: 3 out of 5 stars3/5Java Programming Tutorial With Screen Shots & Many Code Example Rating: 0 out of 5 stars0 ratingsThe Essential R Reference Rating: 0 out of 5 stars0 ratingsIntroduction to PHP, Part 2, Second Edition Rating: 0 out of 5 stars0 ratingsObject-Oriented JavaScript - Third Edition Rating: 4 out of 5 stars4/5Learn C++ Rating: 4 out of 5 stars4/5Mastering Objectoriented Python Rating: 5 out of 5 stars5/5Oracle Application Express 3.2: The Essentials and More Rating: 0 out of 5 stars0 ratingsMastering TypoScript: TYPO3 Website, Template, and Extension Development Rating: 0 out of 5 stars0 ratingsBackbase 4 RIA Development Rating: 0 out of 5 stars0 ratingsIan Talks JS A-Z: WebDevAtoZ, #1 Rating: 0 out of 5 stars0 ratingsLearning JavaScript Data Structures and Algorithms - Second Edition Rating: 0 out of 5 stars0 ratingsMastering Swift Rating: 0 out of 5 stars0 ratingsJava Problems with Solutions Rating: 5 out of 5 stars5/5JSF 1.2 Components Rating: 0 out of 5 stars0 ratingsMastering JavaScript: The Complete Guide to JavaScript Mastery Rating: 5 out of 5 stars5/5Mastering phpMyAdmin 3.4 for Effective MySQL Management Rating: 0 out of 5 stars0 ratingsJavaScript Introduction Rating: 0 out of 5 stars0 ratingsIntroduction to Algorithms Rating: 0 out of 5 stars0 ratingsMastering Elastic Stack Rating: 0 out of 5 stars0 ratingsCryENGINE Game Programming with C++, C#, and Lua Rating: 0 out of 5 stars0 ratingsObject-Oriented JavaScript Rating: 4 out of 5 stars4/5Excel 2013 Power Programming with VBA Rating: 5 out of 5 stars5/5JavaScript for .NET Developers Rating: 0 out of 5 stars0 ratingsMastering Joomla! 1.5 Extension and Framework Development: The Professional Guide to Programming Joomla! Rating: 4 out of 5 stars4/5MySQL for Python Rating: 5 out of 5 stars5/5TypeScript: Modern JavaScript Development Rating: 0 out of 5 stars0 ratingsBeginning C# and .NET Rating: 0 out of 5 stars0 ratingsMastering phpMyAdmin 3.3.x for Effective MySQL Management Rating: 0 out of 5 stars0 ratingsMCSD Certification Toolkit (Exam 70-483): Programming in C# Rating: 3 out of 5 stars3/5
Internet & Web For You
Get Rich or Lie Trying: Ambition and Deceit in the New Influencer Economy Rating: 0 out of 5 stars0 ratingsNo Place to Hide: Edward Snowden, the NSA, and the U.S. Surveillance State Rating: 4 out of 5 stars4/5How to Be Invisible: Protect Your Home, Your Children, Your Assets, and Your Life Rating: 4 out of 5 stars4/5Coding For Dummies Rating: 5 out of 5 stars5/5Six Figure Blogging Blueprint Rating: 5 out of 5 stars5/5How to Disappear and Live Off the Grid: A CIA Insider's Guide Rating: 0 out of 5 stars0 ratingsCoding All-in-One For Dummies Rating: 4 out of 5 stars4/5Mike Meyers' CompTIA Security+ Certification Guide, Third Edition (Exam SY0-601) Rating: 5 out of 5 stars5/5Everybody Lies: Big Data, New Data, and What the Internet Can Tell Us About Who We Really Are Rating: 4 out of 5 stars4/5The Gothic Novel Collection Rating: 5 out of 5 stars5/5Podcasting For Dummies Rating: 4 out of 5 stars4/5The $1,000,000 Web Designer Guide: A Practical Guide for Wealth and Freedom as an Online Freelancer Rating: 5 out of 5 stars5/5Social Engineering: The Science of Human Hacking Rating: 3 out of 5 stars3/5Cybersecurity For Dummies Rating: 4 out of 5 stars4/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5The Hacker Crackdown: Law and Disorder on the Electronic Frontier Rating: 4 out of 5 stars4/5Hacking : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Ethical Hacking Rating: 5 out of 5 stars5/5Stop Asking Questions: How to Lead High-Impact Interviews and Learn Anything from Anyone Rating: 5 out of 5 stars5/5Remote/WebCam Notarization : Basic Understanding Rating: 3 out of 5 stars3/5The Digital Marketing Handbook: A Step-By-Step Guide to Creating Websites That Sell Rating: 5 out of 5 stars5/5Beginner's Guide To Starting An Etsy Print-On-Demand Shop Rating: 0 out of 5 stars0 ratingsThe Logo Brainstorm Book: A Comprehensive Guide for Exploring Design Directions Rating: 4 out of 5 stars4/5The Beginner's Affiliate Marketing Blueprint Rating: 4 out of 5 stars4/5Web Designer's Idea Book, Volume 4: Inspiration from the Best Web Design Trends, Themes and Styles Rating: 4 out of 5 stars4/5C++ Learn in 24 Hours Rating: 0 out of 5 stars0 ratingsThe Designer's Web Handbook: What You Need to Know to Create for the Web Rating: 0 out of 5 stars0 ratings
Reviews for jQuery 1.4 Reference Guide
2 ratings0 reviews
Book preview
jQuery 1.4 Reference Guide - Jonathan Chaffer
Table of Contents
jQuery 1.4 Reference Guide
Credits
About the Authors
About the Reviewers
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Errata
Piracy
Questions
1. Anatomy of a jQuery Script
A dynamic table of contents
Obtaining jQuery
Setting up the HTML document
Writing the jQuery code
Script dissection
Selector expressions
DOM traversal methods
DOM manipulation methods
Event methods
Effect methods
AJAX methods
Miscellaneous methods
Plug-in API
Summary
2. Selector Expressions
CSS selectors
Element (T)
Examples
Description
ID (#myid)
Examples
Description
Class (.myclass)
Examples
Description
Descendant (E F)
Examples
Description
Child (E > F)
Examples
Description
Adjacent sibling (E + F)
Examples
Description
General sibling (E ~ F)
Examples
Description
Multiple expressions (E, F, G)
Examples
Description
Numbered child (:nth-child(n/even/odd/expr))
Examples
Description
First child (:first-child)
Examples
Description
Last child (:last-child)
Examples
Description
Only child (:only-child)
Examples
Not (:not(E))
Examples
Empty (:empty)
Examples
Description
Universal (*)
Examples
Description
Attribute selectors
Attribute ([foo])
Examples
Attribute equals ([foo=bar])
Examples
Description
Attribute does not equal ([foo!=bar])
Examples
Description
Attribute begins with ([foo^=bar])
Examples
Description
Attribute ends with ([foo$=bar])
Examples
Attribute contains ([foo*=bar])
Examples
Description
Attribute contains word ([foo~=bar])
Examples
Description
Attribute contains prefix ([foo|=bar])
Examples
Description
Form selectors
Custom selectors
Element at index (:eq(n))
Examples
Description
Greater than (:gt(n))
Examples
Description
Less than (:lt(n))
Examples
Description
First (:first)
Examples
Description
Last (:last)
Examples
Description
Even element (:even)
Examples
Description
Odd element (:odd)
Examples
Description
Is parent (:parent)
Examples
Description
Contains text (:contains(text))
Examples
Description
Contains element (:has(E))
Examples
Description
Visible (:visible)
Examples
Description
Hidden (:hidden)
Examples
Description
Header element (:header)
Examples
Currently animating (:animated)
Examples
3. DOM Traversal Methods
The jQuery function
$()
Parameters (first version)
Parameters (second version)
Parameters (third version)
Parameters (fourth version)
Parameters (fifth version)
Return value
Description
Selector context
Using DOM elements
Cloning jQuery objects
Creating new elements
Filtering methods
.filter()
Parameters (first version)
Parameters (second version)
Return value
Description
Using a filter function
.not()
Parameters (first version)
Parameters (second version)
Parameters (third version)
Return value
Description
Removing specific elements
.has()
Parameters
Return value
Description
.eq()
Parameters
Return value
Description
.first()
Parameters
Return value
Description
.last()
Parameters
Return value
Description
.slice()
Parameters
Return value
Description
Negative indices
Tree traversal methods
.find()
Parameters
Return value
Description
.children()
Parameters
Return value
Description
.parents()
Parameters
Return value
Description
.parentsUntil()
Parameters
Return value
Description
.parent()
Parameters
Return value
Description
.closest()
Parameters
Return value
Description
.offsetParent()
Parameters
Return value
Description
.siblings()
Parameters
Return value
Description
.prev()
Parameters
Return value
Description
.prevAll()
Parameters
Return value
Description
.prevUntil()
Parameters
Return value
Description
.next()
Parameters
Return value
Description
.nextAll()
Parameters
Return value
Description
.nextUntil()
Parameters
Return value
Description
Miscellaneous traversal methods
.add()
Parameters (first version)
Parameters (second version)
Parameters (third version)
Return value
Description
.is()
Parameters
Return value
Description
.end()
Parameters
Return value
Description
.andSelf()
Parameters
Return value
Description
.map()
Parameters
Return value
Description
.contents()
Parameters
Return value
Description
4. DOM Manipulation Methods
General attributes
.attr() (getter)
Parameters
Return value
Description
.attr() (setter)
Parameters (first version)
Parameters (second version)
Parameters (third version)
Return value
Description
Setting a simple attribute
Setting several attributes at once
Computed attribute values
.removeAttr()
Parameters (first version)
Parameters (second version)
Return value
Description
Style properties
.css() (getter)
Parameters
Return value
Description
.css() (setter)
Parameters (first version)
Parameters (second version)
Parameters (third version)
Return value
Description
.height() (getter)
Parameters
Return value
Description
.height() (setter)
Parameters
Return value
Description
.innerHeight()
Parameters
Return value
Description
.outerHeight()
Parameters
Return value
Description
.width() (getter)
Parameters
Return value
Description
.width() (setter)
Parameters
Return value
Description
.innerWidth()
Parameters
Return value
Description
.outerWidth()
Parameters
Return value
Description
.offset() (getter)
Parameters
Return value
Description
.offset() (setter)
Parameters
Return value
Description
.position()
Parameters
Return value
Description
.scrollTop() (getter)
Parameters
Return value
Description
.scrollTop() (setter)
Parameters
Return value
.scrollLeft() (getter)
Parameters
Return value
Description
.scrollLeft() (setter)
Parameters
Return value
Class attributes
.hasClass()
Parameters
Return value
Description
.addClass()
Parameters (first version)
Parameters (second version)
Return value
Description
.removeClass()
Parameters (first version)
Parameters (second version)
Return value
Description
.toggleClass()
Parameters (first version)
Parameters (second version)
Parameters (third version)
Return value
Description
DOM replacement
.html() (getter)
Parameters
Return value
Description
.html() (setter)
Parameters (first version)
Parameters (second version)
Return value
Description
.text() (getter)
Parameters
Return value
Description
.text() (setter)
Parameters (first version)
Parameters (second version)
Return value
Description
.val() (getter)
Parameters
Return value
Description
.val() (setter)
Parameters (first version)
Parameters (second version)
Return value
Description
.replaceWith()
Parameters
Return value
Description
.replaceAll()
Parameters
Return value
Description
DOM insertion, inside
.prepend()
Parameters (first version)
Parameters (second version)
Return value
Description
.prependTo()
Parameters
Return value
Description
.append()
Parameters (first version)
Parameters (second version)
Return value
Description
.appendTo()
Parameters
Return value
Description
DOM insertion, outside
.before()
Parameters (first version)
Parameters (second version)
Return value
Description
.insertBefore()
Parameters
Return value
Description
.after()
Parameters (first version)
Parameters (second version)
Return value
Description
.insertAfter()
Parameters
Return value
Description
DOM insertion, around
.wrap()
Parameters (first version)
Parameters (second version)
Return value
Description
.wrapAll()
Parameters
Return value
Description
.wrapInner()
Parameters (first version)
Parameters (second version)
Return value
Description
DOM copying
.clone()
Parameters
Return value
Description
DOM removal
.empty()
Parameters
Return value
Description
.remove()
Parameters
Return value
Description
.detach()
Parameters
Return value
Description
.unwrap()
Parameters
Return value
Description
5. Event Methods
Event handler attachment
.bind()
Parameters
Return value
Description
Event handlers
The event object
Passing event data
.unbind()
Parameters (first version)
Parameters (second version)
Return value
Description
Using namespaces
Using the event object
.one()
Parameters
Return value
Description
.trigger()
Parameters
Return value
Description
.triggerHandler()
Parameters
Return value
Description
.live()
Parameters
Return value
Description
Event delegation
Caveats
.die()
Parameters
Return value
Description
Document loading
.ready()
Parameters
Return value
Description
Aliasing the jQuery namespace
.load()
Parameters
Return value
Description
.unload()
Parameters
Return value
Description
.error()
Parameters
Return value
Description
Mouse events
.mousedown()
Parameters (first version)
Return value
Description
.mouseup()
Parameters (first version)
Return value
Description
.click()
Parameters (first version)
Return value
Description
.dblclick()
Parameters (first version)
Return value
Description
.toggle()
Parameters
Return value
Description
.mouseover()
Parameters (first version)
Return value
Description
.mouseout()
Parameters (first version)
Return value
Description
.mouseenter()
Parameters (first version)
Return value
Description
.mouseleave()
Parameters (first version)
Return value
Description
.hover()
Parameters
Return value
Description
.mousemove()
Parameters (first version)
Return value
Description
Form events
.focus()
Parameters (first version)
Return value
Description
.blur()
Parameters (first version)
Return value
Description
.change()
Parameters (first version)
Return value
Description
.select()
Parameters (first version)
Return value
Description
.submit()
Parameters (first version)
Return value
Description
Keyboard events
.keydown()
Parameters (first version)
Return value
Description
.keypress()
Parameters (first version)
Return value
Description
.keyup()
Parameters (first version)
Return value
Description
Browser events
.resize()
Parameters (first version)
Return value
Description
.scroll()
Parameters (first version)
Return value
Description
6. Effect Methods
Pre-packaged effects
.show()
Parameters
Return value
Description
.hide()
Parameters
Return value
Description
.toggle()
Parameters (first version)
Parameters (second version)
Return value
Description
.slideDown()
Parameters
Return value
Description
.slideUp()
Parameters
Return value
Description
.slideToggle()
Parameters
Return value
Description
.fadeIn()
Parameters
Return value
Description
.fadeOut()
Parameters
Return value
Description
.fadeTo()
Parameters
Return value
Description
Customized effects
.animate()
Parameters (first version)
Parameters (second version)
Return value
Description
.stop()
Parameters
Return value
Description
.delay()
Parameters
Return value
Description
.queue()
Parameters (first version)
Parameters (second version)
Parameters (third version)
Return value (first version)
Return value (second and third versions)
Description
.dequeue()
Parameters
Return value
Description
.clearQueue()
Parameter
Return value
Description
7. AJAX Methods
Low-level interface
$.ajax()
Parameters
Return value
Description
Callback functions
Data types
Sending data to the server
Advanced options
$.ajaxSetup()
Parameters
Return value
Description
Shorthand methods
$.get()
Parameters
Return value
Description
.load()
Parameters
Return value
Description
Loading page fragments
$.post()
Parameters
Return value
Description
$.getJSON()
Parameters
Return value
Description
$.getScript()
Parameters
Return value
Description
Global AJAX event handlers
.ajaxComplete()
Parameters
Return value
Description
.ajaxError()
Parameters
Return value
Description
.ajaxSend()
Parameters
Return value
Description
.ajaxStart()
Parameters
Return value
Description
.ajaxStop()
Parameters
Return value
Description
.ajaxSuccess()
Parameters
Return value
Description
Helper functions
.serialize()
Parameters
Return value
Description
.serializeArray()
Parameters
Return value
Description
8. Miscellaneous Methods
Setup methods
$.noConflict()
Parameters
Return value
Description
DOM element methods
.size()
Return value
Description
.get()
Parameters
Return value
Description
.index()
Parameters (first version)
Return value (first version)
Parameters (second version)
Return value (second version)
Parameters (third version)
Return value (third version)
Description
Collection manipulation
.each()
Parameters (first version)
Return value (first version)
Parameters (second version)
Return value (second version)
Description
$.grep()
Parameters
Return value
Description
$.makeArray()
Parameters
Return value
Description
$.inArray()
Parameters
Return value
Description
$.map()
Parameters
Return value
Description
$.merge()
Parameters
Return value
Description
$.unique()
Parameters
Return value
Description
$.extend()
Parameters
Return value
Description
$.trim()
Parameters
Return value
Description
$.param()
Parameters
Return value
Description
Introspection
$.isArray()
Parameters
Return value
$.isFunction()
Parameters
Return value
$.isPlainObject()
Parameters
Return value
$.isEmptyObject()
Parameters
Return value
$.isXMLDoc()
Parameters
Return value
Data storage
.data()
Parameters (first version)
Return value (first version)
Parameters (second version)
Return value (second version)
Parameters (third version)
Return value (third version)
Description
.removeData()
Parameters
Return value
Description
9. jQuery Properties
Global properties
$.browser
$.support
$.support.boxModel
$.support.cssFloat
$.support.hrefNormalized
$.support.htmlSerialize
$.support.leadingWhitespace
$.support.noCloneEvent
$.support.objectAll
$.support.opacity
$.support.scriptEval
$.support.style
$.support.tbody
jQuery object properties
.length
.selector
.context
10. The Plug-in API
Using a plug-in
Developing a plug-in
Object method
Components
Description
Global function
Components (first and second versions)
Components (third version)
Description
Plug-ins with a single function
Plug-ins with multiple functions
Example: A simple print function
Selector expression
Components
Description
Plug-in conventions
Use of the $ alias
Naming conventions
API standardization
11. Alphabetical Quick Reference
Selector expressions
Methods
Properties
A. Online Resources
jQuery documentation
Official jQuery documentation
jQuery API browser
Adobe AIR jQuery API Viewer
JavaScript reference
Mozilla Developer Center
Client-Side JavaScript Reference
MSDN Reference
Dev.Opera
Quirksmode
JavaScript Toolbox
comp.lang.javascript FAQ
JavaScript code compressors
JSMin
YUI Compressor
Google Closure Compiler
Packer
JavaScript code decompressors
Pretty Printer
JavaScript beautifier
(X)HTML reference
W3C Hypertext Markup Language Home Page
CSS reference
W3C Cascading Style Sheets Home Page
Mezzoblue CSS Crib Sheet
Position Is Everything
Useful blogs
The jQuery blog
Learning jQuery
jQuery for Designers
Ajaxian
John Resig
JavaScript Ant
Robert's talk
Snook
Paul Irish
NCZOnline
I Can't
DOM scripting
Steve Souders
As days pass by
A List Apart
Web development frameworks using jQuery
B. Development Tools
Tools for Firefox
Firebug
Web Developer toolbar
Venkman
Regular Expressions Tester
Tools for Internet Explorer
Microsoft Internet Explorer Developer Toolbar
Microsoft Internet Explorer 8 Developer Tools
Microsoft Visual Web Developer Express
dynaTrace AJAX Edition
DebugBar
Drip
Tools for Safari
Develop menu
Tools for Opera
Dragonfly
Other tools
Firebug Lite
NitobiBug
TextMate jQuery Bundle
jQuerify Bookmarklet
Charles
Fiddler
Sloppy
JS Bin
Bespin
Aptana
Index
jQuery 1.4 Reference Guide
Karl Swedberg
Jonathan Chaffer
jQuery 1.4 Reference Guide
Copyright © 2010 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: January 2010
Production Reference: 1190110
Published by Packt Publishing Ltd.
32 Lincoln Road
Olton
Birmingham, B27 6PA, UK.
ISBN 978-1-84951-004-2
www.packtpub.com
Cover Image by Karl Swedberg (<karl@englishrules.com>)
Credits
Authors
Karl Swedberg
Jonathan Chaffer
Reviewers
Joydip Kanjilal
Dave Methvin
Acquisition Editor
Swapna V. Verlekar
Development Editor
Swapna V. Verlekar
Technical Editor
Tariq Rakhange
Copy Editor
Sneha Kulkarni
Indexer
Hemangini Bari
Production Editorial Manager
Abhijeet Deobhakta
Editorial Team Leader
Mithun Sehgal
Project Team Leader
Lata Basantani
Project Coordinator
Joel Goveya
Proofreader
Chris Smith
Graphics
Nilesh R. Mohite
Production Coordinator
Dolly Dasilva
Cover Work
Dolly Dasilva
About the Authors
Karl Swedberg is a web developer at Fusionary Media in Grand Rapids, Michigan, where he spends much of his time solving problems with JavaScript and implementing design. A member of the jQuery Project Team and an active contributor to the jQuery discussion list, Karl has presented at workshops and conferences, and provided corporate training in Europe and North America.
Before he got hooked on to web development, Karl worked as a copy editor, a high-school English teacher, and a coffee house owner. He gave up his dream of becoming a professional musician in the early 1990s about the same time that he stumbled into a job at Microsoft in Redmond, Washington. He sold his hollow-body Rickenbacker ages ago, but still keeps an acoustic guitar in the basement.
I wish to thank my wife, Sara, for keeping me sane. Thanks also to my two delightful children, Benjamin and Lucia. Jonathan Chaffer has my deepest respect for his programming expertise and my gratitude for his willingness to write this book with me.
Many thanks to John Resig for creating the world's greatest JavaScript library and for fostering an amazing community around it. Thanks also to the folks at Packt Publishing, the technical reviewers of this book, the jQuery Cabal, and the many others who have provided help and inspiration along the way.
Jonathan Chaffer is a member of Rapid Development Group, a web development firm located in Grand Rapids, Michigan. His work there includes overseeing and implementing projects in a wide variety of technologies, with an emphasis on PHP, MySQL, and JavaScript.
In the open source community, Jonathan has been very active in the Drupal CMS project, which has adopted jQuery as its JavaScript framework of choice. He is the creator of the Content Construction Kit, a popular module for managing structured content on Drupal sites. He is responsible for major overhauls of Drupal's menu system and developer API reference.
Jonathan lives in Grand Rapids with his wife, Jennifer.
I would like to thank Jenny for her tireless enthusiasm and support, Karl for the motivation to continue writing when the spirit was weak, and the Ars Technica community for constant inspiration toward technical excellence.
About the Reviewers
Joydip Kanjilal is a Microsoft MVP in ASP.NET, and the author of a number of books on .NET and its related technologies. He has over 12 years of industry experience in IT with more than 6 years in Microsoft .NET and its related technologies. He has authored a lot of articles for some of the most reputable sites such as www.asptoday.com, www.devx.com, www.aspalliance.com, www.aspnetpro.com, www.mcpressonline.com, www.sql-server-performance.com, www.sswug.com, and so on. A lot of these articles have been selected at www.asp.net—Microsoft's official site on ASP.NET. Joydip was also a community credit winner at www.community-credit.com a number of times. Joydip was also selected as MSDN Featured Developer of the Fortnight in November and December, 2008. Joydip has authored the following books:
ASP.NET 4.0 Programming (Mc-Graw Hill Publishing)
Entity Framework Tutorial (Packt Publishing)
Pro Sync Framework (APRESS)
Sams Teach Yourself ASP.NET Ajax in 24 Hours (Sams Publishing)
ASP.NET Data Presentation Controls Essentials (Packt Publishing)
He is currently working as an independent software consultant and author. He has years of experience in designing and architecting solutions for various domains. His technical strengths include C, C++, VC++, Java, C#, Microsoft .NET, AJAX, Design Patterns, SQL Server, Operating Systems, and Computer Architecture. Joydip blogs at http://aspadvice.com/blogs/joydip and spends his time reading books, blogs, and writing books and articles. His hobbies include watching cricket, soccer, and playing chess.
Dave Methvin is the Chief Technology Officer at PC Pitstop and one of the founding partners of the company. He provides technical direction for the PCPitstop.com (http://www.pcpitstop.com/) web site and oversees software development.
Before joining PC Pitstop, Dave had an extensive career in computer journalism. He served as an Executive Editor at both Windows Magazine and PC Tech Journal, co-authored a book on Windows NT networking, and wrote articles for more than two dozen publications. Dave blogs on Windows issues for the InformationWeek (http://www.informationweek.com) web site.
Dave holds both a bachelor's and a master's degree in Computer Science from the University of Virginia. He has been active in the jQuery community since 2006 and has written several popular plug-ins such as Splitter.
Preface
jQuery is a powerful, yet easy-to-use, JavaScript library that helps web developers and designers add dynamic, interactive elements to their sites, smoothing out browser inconsistencies and greatly reducing development time. In jQuery 1.4 Reference Guide, you can investigate this library's features in a thorough, accessible format.
This book offers an organized menu of every jQuery method, function, and selector. Entries are accompanied by detailed descriptions and helpful recipes that will assist you in getting the most out of jQuery, and avoiding the pitfalls commonly associated with JavaScript and other client-side languages. If you're still hungry for more, the book shows you how to cook up your own extensions with jQuery's elegant plug-in architecture.
You'll discover the untapped possibilities that jQuery makes available and hone your skills as you return to this guide time and again.
What this book covers
In Chapter 1, Anatomy of a jQuery Script, we'll begin by dissecting a working jQuery example. This script will serve as a roadmap for this book, directing you to the chapters containing more information on particular jQuery capabilities.
The heart of the book is a set of reference chapters, which allow you to quickly look up the details of any jQuery method. Chapter 2, Selector Expressions, lists every available selector for finding page elements.
Chapter 3, DOM Traversal Methods, builds on the previous chapter with a catalog of jQuery methods for finding page elements.
Chapter 4, DOM Manipulation Methods, describes every opportunity for inspecting and modifying the HTML structure of a page.
Chapter 5, Event Methods, details each event that can be triggered and reacted to by jQuery.
Chapter 6, Effect Methods, defines the range of animations built into jQuery, as well as the toolkit available for building your own.
Chapter 7, AJAX Methods, lists the ways in which jQuery can initiate and respond to server communication without refreshing the page.
Chapter 8, Miscellaneous Methods, covers the remaining capabilities of the jQuery library that don't neatly fit into the other categories.
Chapter 9, jQuery Properties, lists properties of the jQuery object that can be inspected for information about the browser environment.
With the catalog of built-in functionality concluded, we'll dive into the extension mechanisms jQuery makes available. Chapter 10, Plug-in API, reveals these powerful ways to enhance jQuery's already robust capabilities using a plug-in.
Chapter 11, Alphabetical Quick Reference, offers a handy list of all methods and their arguments.
Appendix A, Online Resources, provides a handful of informative web sites on a wide range of topics related to jQuery, JavaScript, and web development in general.
Appendix B, Development Tools, recommends a number of useful third-party programs and utilities for editing and debugging jQuery code within your personal development environment.
What you need for this book
This book is a reference guide, not a tutorial. As such, prior exposure to the jQuery library will be beneficial in navigating this reference. The book Learning jQuery 1.3 is well-suited for this purpose.
To understand jQuery concepts, some knowledge of JavaScript is required, and familiarity with HTML and CSS is helpful.
The jQuery library itself can be downloaded from http://jquery.com/. The majority of examples in this book require only this library, a text editor, and a web browser. Some AJAX examples require web server software as well, such as Apache, but this requirement is avoided wherever possible.
Who this book is for
This reference is designed for web developers who want a broad, organized view of all that the jQuery library has to offer, or want a quick reference on their desks to refer to for particular details. Basic knowledge of HTML and CSS is required. You should be comfortable with the syntax of JavaScript, and have basic knowledge of jQuery to make best use of this book.
Conventions
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text are shown as follows: The .removeAttr() method uses the JavaScript removeAttribute() function.
A block of code is set as follows: