index
Symbols $.trim() 9, 168 request life cycle 223
$.unique() 176 request parameters 221
$ responses 223224
as function namespace 154 A responseText 223
as namespace prefix 9 responseXML 223
avoiding name collisions abbr element 262 setting defaults 252253
189 ActiveX control 218 uploading files 284
defining locally 164 Adaptive Path 218 XML, not using 223
in plugins 189 add() 36, 247 ajaxForm Lab 282, 284
in ready handler 165 addClass() 59 ajaxForm() 282
naming conflicts 14 adding a wrapper method ajaxFormUnbind() 282
sharing with other libraries 199201 ajaxSubmit Lab 279280
164 adding select options 159 ajaxSubmit() 277, 279
$() 6 after() 73 alpha filters 62
adding wrapper methods Ajax 218226 andSelf() 47
216 comprehensive 258266 animate () 145, 148
for element creation 11 comprehensive jQuery API animations
$.ajax() 249, 261, 278 249252 CSS properties 146
$.ajaxSetup() 252 diagrammed 223 custom drop 148150
$.browser 157, 247 Form Plugin, using 276284 custom fading 147
$.each() 169 form submission via 276 custom puff 150151
$.extend() 177, 191, 210, 261 284 custom scale 148
$.fn 199, 246, 259 GET 235236 easing 147
$.get() 236, 252 Global Callback Info object stopping 145
$.getJSON() 237, 241 253 using Flash 127
$.getScript() 180 global functions 254258 anonymous event handler
$.grep() 170 growth catalyst 2 86
$.inArray() 175 HTTP requests 233234 anonymous functions 165
$.livequery.run() 294 iframes, using 218 anonymous listeners 86
$.makeArray() 175 initilizing 219 API. See jQuery API
$.map() 172 loading content 226 append() 70
$.noConflict() 164, 189, 192 loadng scripts 181 appending content 70, 72
$.post() 248, 252 POST requests 248249 appendTo() 71
$.styleFloat 163 ready state handler 221 appetizer menu 113124
339
340 INDEX
Application Programming chain 7 custom animations 145151
Interface. See jQuery API managing 4547 custom attributes 5253
arrays, filtering 170172 chaining 4547 custom properties 211
assigning properties 51 change() 102, 231 custom selectors 2730
Asynchronous JavaScript and child selector 21
XML. See Ajax children() 43 D
attr() 52, 5455 class names
attribute selectors 22 adding, removing 5860 data conversion 173
attributes 49 fetching 67 data translation 172176
applying 5658 Clear and Reset Lab 274 Date 195
diagrammed 50 clearForm() 275 date formatting 195199
Internet Explorer limita- click() 102, 107 dblclick() 102
tions 56 clone() 45, 78 defining functions 193
normalized values 53 closures 84, 90, 211, 334337 dependent dropdowns 237
removing 56 code consistency, reusability DHTML 49
setting 5456 186 dimensions 286289
values, fetching 5254 collapsible list, implementing Dimensions Plugin 285291
augmenting wrapped sets 38 128134 height() 285
collecting properties 52 innerHeight() 286
B collisions, naming 187189 innerWidth() 286
command chain 7 offset() 290
Basic Event Model 84 managing 4547 offsetParent() 290
before() 73 commands 17 outerHeight() 286
behavior, separating from commerce 229 outerWidth() 286
structure 4 container selector 23 position() 290
bind() 98, 293 contains() 44 scrollLeft() 287
black box 225 content scrolling 287 scrollTop() 287
blur() 102, 107 contents() 43 width() 285
Boot Closet page 264266 copying Dimensions Plugin Scrolling
box model 161, 286 address information 202 Lab 287
diagrammed 162 206 exercises 289
browser detection 155161 elements 78 disabling form elements 13
alternatives 156157 creating DOM elements 11 DOCTYPE 161
jQuery flags 157163 creating utility functions 194, Document Object Model
bubble phase 94 196199 (DOM) 10, 17, 4958
bubbling 8890 cross-browser Ajax 219 cloning elements 78
stopping 91 CSS copying elements 70, 7880
absolute positioning 150 creating new elements 11
C hiding elements 128 event bubbling 8890
inline vs block 128 form elements 7980
callback functions 329330 offset parent 289 generating elements 3132
Camino 155160, 328 opacity 142, 147 manipulation 68
reloading 306 overflow 289 moving elements 7080
capability detection 156 relative positioning 149 NodeList 50
capture phase 94 styling lists 132 removing elements 7677
cascading dropdowns 237245 See also Cascading Style replacing elements 77
Cascading Style Sheets 2 Sheet setting content 68
class names 58, 67 css() 6162, 132, 200 wrapping elements 75
comma operator 38 CSS3 6 document ready handler 9
INDEX 341
document scrolling 288 hide 127 event models
DOM elements, positioning show 127 Basic 8587
285291 sliding 143144 DOM Level 0 8587
DOM Level 0 8587 elements DOM Level 2 9196
DOM Level 1 84 abbr 262 Internet Explorer 97
DOM Level 2 9196 animating 135145 jQuery 98124
DOM manipulation 258 attributes 4958 Netscape 8587
DOM. See Document Object cloning 78 event propagation 106
Model (DOM) content 6870 diagrammed 95
Double Submit Problem 57 copying 70, 7880 event, toggling 108
drag-and-drop 300 event handlers 85 event-driven interfaces 83
draggable() 300, 304 fading 140 events 112124
draggableDestroy() 303 form elements 7980 addEventListener() 92
draggableDisable() 304 listeners 85 attachEvent() 97
draggableEnable() 304 moving 7080 binding 98
draggables 300308 properties 4958 bubble phase 94
axis of movement 307 removing 7677 bubbling 8890
constraining 307 replacing 77 cancelling propagation 91
containment 307 selecting 17 capture phase 94
grid 308 setting content 68 establishing multiple 9294
required files 301 showing and hiding 127 Event instance 88
suitability concept 309 130 key codes 105
dropdowns 237 sliding 143144 modifier keys 105
droppable() 308 span 262 propagation 9496
droppableDestroy() 314 styling 5868 semantic actions 106
droppableDisable() 315 title attribute 258 srcElement 88
droppableEnable() 315 toggling 134 stopping propagation 106
droppables 308315 wrapping 75 target element 88
drop event 309 empty() 77 triggering 106107
options 309 emptying select elements expando 211
required files 308 246 expire() 295
state transition diagram encodeURIComponent() 221 extending jQuery 13, 186216
309 end() 46 comprehensive examples
states 309 error callback 253 245
dynamically loading scripts error() 102 defining wrapper methods
180183 event handlers 83 199216
anonymous 86 emptying select elements
E as attributes 86 246
removing 103 implementation functions
each() 13, 51, 90, 148, 200, 211, toggling 108110 212214
246, 337 event handling in $ namespace 192193
easing 147 hovering 110112 loading select elements 246
Easing Plugin 147 proactive 292293 motivations 186187
effects 127 Event instance 87, 104 naming files 188
custom drop 148 cancelBubble 91 The Termifier 260264
custom fading 147 normalizing 104 utility functions 192193
custom puff 150 preventDefault() 106 extending objects 176180
custom scale 148 stopPropagation() 91, 106
fading 140 target 107
342 INDEX
F resetForm() 275 H
uploading files 284
fadeIn() 141 form submission halting form submission 91
fadeOut() 141 hijacking 281284 hasClass() 67
fadeTo() 142 semantic events 282 hash as parameter 190192
fieldSerialize() 272 via Ajax 281284 height() 6364, 285
fieldValue() 270272 via focusable element 284 hide() 127, 135
filesystem browsing 128 formatting fixed-width out- hover() 111
filter selectors 29 put 194 hovering 110112
filter() 41, 202 forms, serializing 227 HTML 5 Draft Specification
filtering data 170172 formSerialize() 272 262
filtering wrapped sets 40 Function HTML Specification 270
find selectors 29 apply() 331 html() 7, 68
find() 44 as first-class object 326 HTML, generation 3132
Firebug 321 call() 331 HTTP. See Hypertext Trans-
Firefox 155, 160, 321, 328 function keyword opera- fer Protocol (HTTP)
reload vs. refresh 140 tion 327 Hypertext Transfer Protocol
reloading 306 naming 327328 (HTTP) 83, 248
fixed-width output 193 function context 84, 200, methods 221, 227
194 330331 effects on caching 234
flags 154 functional programming 334 status codes 222
$.boxModel 161 functions
$.browser 157 as callbacks 329330 I
$.styleFloat 163 as methods 328, 334
Flash 127 assigning context 331 idempotent requests 234
float styles, browser differ- context 330 iframe 284
ences 163 function literal 327 implementation functions 213
flyout 258 top-level 327 index() 36
focus() 102, 107 information overload 128, 130
form controls G inheritance 176
clearing 274276 innerHeight() 286
resetting 274276 Gecko 158, 328 innerWidth() 286
serializing 272274 GET 221, 227, 234, 261 insertAfter() 73
submission order 273 Get Form Value(s) Lab 271, insertBefore() 73
successful concept 270 273 inserting dynamic HTML 74
form elements 7980 get() 35 Internet Explorer 155, 158,
Form Plugin 80, 269284 GIF 266 160
ajaxForm Lab 282 global Ajax functions 253258 box model 161
ajaxForm() 282 Global Callback Info object 253 event handling limitations
ajaxFormUnbind() 282 global flags 154 96
ajaxSubmit Lab 279 global namespace 14 Event Model 97
ajaxSubmit() 277 polluting 198 inverting selectors 2930
Clear and Reset Lab 274 Google 218 is() 45, 67, 132, 135
clearForm() 275 Graphical User Interface iterating 51
download location 269 (GUI) 83 properties and collections
fieldSerialize() 272 drag-and-drop 300 169170
fieldValue() 271 grep 170
formSerialize() 272 GUI. See Graphical User
Get Form Value Lab 271 Interface (GUI)
INDEX 343
J Unobtrusive JavaScript 35 $.noConflict 164
var keyword explained 325 $.post() 248
Java Swing 83 window properties 325 $.styleFloat 163
JavaScript XML and 223 $.trim() 9, 168
. operator 323 Jedi mind tricks 327 $.unique() 176
adding select options 158 Jesse James Garrett 218 addClass() 59
advanced example 258 jQuery 25 after() 73
closure variables 335 $() 6 ajaxComplete() 254
closures 84, 211, 334337 add() 36 ajaxError() 254
creating objects 320 browser detection flags ajaxSend() 254
Date 195 157163 ajaxStart() 254
dot operator 323 chaining 7, 186, 200, 261 ajaxStop() 254
dynamic creation of chains 4547 ajaxSuccess() 254
properties 321 commands 17 andSelf() 47
essential concepts 320 contains() 44 animate() 145
extending objects 176 CSS implementation 20 append() 70
for loop 169 custom selectors 2730 appendTo() 71
for-in loop 169 document ready handler 9 attr() 52, 5455
Function 84 DOM manipulation 17 before() 73
function contexts 84, 200 essential JavaScript bind() 98
function keyword 327 concepts 319 blur() 102, 107
functions 326 Event Model 99 change() 102
general reference operator extending 1213, 186216 children() 43
323 flags 154 click() 102, 107
getAttribute() 53 global Ajax commands 254 clone() 78
isNaN() 173 manipulating objects 167 contents() 43
libraries 14 180 css() 6162
libraries, using with jQuery plugins 268317 dblclick() 102
163167 selectors 1730 each() 13, 51
NaN 173 translating data 172176 empty() 77
navigator 155 trimming strings 168 end() 46
new operator 320 using with other libraries error() 102
nonstandard property 14, 163167 fadeIn() 141
names 323 utility functions 8, 154 fadeOut() 141
Number 174 wrapper 67 fadeTo() 142
Object 84, 320326 jQuery API filter() 41
object hash 191 $.ajax() 249 find() 44
Object literals 324325 $.ajaxSetup 252 focus() 102, 107
object properties 321323 $.boxModel 161 get() 35
object property diagram $.browser 157 hasClass() 67
322 $.each() 169 height() 6364
object-oriented 176 $.extend() 177 hide() 135
property references 322 $.get() 234236 hover() 111
prototype property 177 $.getJSON() 237 html() 7, 68
regular expressions 172, $.getScript() 180 index() 36
198 $.grep() 170 insertAfter() 73
setAttribute() 53 $.inArray() 175 insertBefore() 73
String 168, 172, 174 $.makeArray() 175 is() 45
top-level scope 325 $.map() 172 jQuery() 6
344 INDEX
jQuery API (continued) as Ajax response 223 M
keydown() 102 JavaScript Dates and 324
keypress() 102 object example 324 match handler 298
keyup() 102 JSP 225 match listeners 294
load() 102, 226 merging objects 179
mousedown() 102 K merging options 210
mousemove() 102 method 334
mouseout() 102 keydown() 102 Microsoft 218
mouseup() 102 keypress() 102 MIME type in Ajax response
next() 43 keyup() 102 223
nextAll() 43 Konqueror 161 mismatch handler 298
noConflict() 14 mismatch listeners 294
not() 39 L mousedown() 102
one() 102 mousemove() 102
parent() 43 Laboratory pages mouseout() 102
parents() 43 ajaxForm Lab 282 mouseup() 102
prepend() 73 ajaxSubmit Lab 279 Move and Copy Lab 72
prependTo() 73 Clear and Reset Lab 274 -moz-opacity 62
prev() 43 Dimensions Plugin Scrolling multi-browser support 159
prevAll() 43 Lab 287 multipart forms 284
ready() 10 Get Form Value Lab 271 multiple class names 58
removeAttr() 56 Get Form Values 271
removeClass() 59 Live Query Lab 296 N
resize() 102 Move and Copy Lab 72
scroll() 102 Selectors Lab 17 name collisions 187189
select() 102, 107 UI Draggables Lab 304 namespace, global 198
serialize() 227 UI Droppables Lab 311 NaN 174
serializeArray() 228 Wrapped Set Lab 33 navigator object 155
show() 136 leveraging jQuery 186 nesting selectors 23
siblings() 43 libraries, using with jQuery 14 .NET framework 83
size() 34 listeners 83 Netscape Communications
slice() 42 match and mismatch 294 Corporation 84
slideDown() 143 proactive 292293 Netscape Event Model 84
slideToggle() 144 Live Query Lab 296 Netscape Navigator 84
slideUp() 144 Live Query Plugin 292299 next() 43
stop() 145 $.livequery.run() 294 nextAll() 43
submit() 102, 107 capabilities 292 noConflict() 14
toggle() 108, 137 expire() 295 NodeList 50, 175
toggleClass() 59 expiring listeners 295 non-idempotent requests
trigger() 106 forcing evaluation 294 234
unbind() 103 livequery() 293294 normalizing event targets 88
unload() 102 load() 102, 226, 231, 252, 263 not() 39
val() 7980 loading content Number.NaN 174
width() 6364 Ajax 224226
wrap() 75 dynamic data 229233 O
jQuery Effects Lab 138144 jQuery 226228
JSON 236, 241, 263, 277, 324 select elements 246 Object
array example 325 literals 324325
array notation 241 properties 321323
INDEX 345
object detection 156, 247 Photomatic jQuery extension ready state handler 222223
feasibility 158 206216 ready() 10
for Ajax 219 PHP 225 real-time data 229
object hash 190192 plain text response 223 regular expression 170
object orientation 176 plugins 268317 relational selectors 20
object-oriented JavaScript creating 186216 removeAttr() 56
176 Dimensions 149 removeClass() 59
objects, extending 176 Dimensions Plugin 285291 removing elements 77
Observable pattern 92 Easing 147 removing wrapped set
offset parent 289 Form Plugin 269284 elements 39
offset() 290 Live Query Plugin 292299 rendering
offsetParent() 290 on the web 269 quirks mode 161
offsets 289291 strategy 269 strict mode 161
OmniWeb 155, 157, 160 UI Plugin 299316 rendering engine 158
one() 102 PNG files 266 replacing elements 77
online retailers 229 position() 290 reporting Ajax errors 253
onload handler, alternative positional selectors 2427 request header 155
to 9 positioning 289 request parameters 221, 227,
onresize 65 positions 289291 236, 264
Opera 155, 157, 160, 247 POST 221, 227, 234, 248249 requests
operator 323 prepend() 73 idempotent 234
options hash 190192, 261 prependTo() 73 non-idempotent 234, 248
extensive example 208 prev() 43 resetForm() 275
used for wrapper method prevAll() 43 resize() 102
261 proactive event handling 292 resources
OS X, dragging images from product description page Form Plugin download 269
browser 305 231233 jQuery plugins 188
outerHeight() 286 progressive disclosure 113, 128 plugins 269
outerWidth() 286 propagation of events 9496 quirksmode.org 161
Outlook Web Access 218 properties 49 UI Plugin URL 300
overflow 289 diagrammed 50 response 223224
of JavaScript objects 321 JSON 236
P 323 responseText 220, 223, 226
property referencing 322 responseXML 223
page rendering 161 Prototype 192 retail web sites 229
parameters 190192 using with jQuery 14, 163 reusability 186
parent() 43 167 reusable components 167
parents() 43 prototype 177, 199 RIA. See Rich Internet Appli-
parsing ZIP codes 172 cation (RIA)
patterns Q Rich Internet Application
necessity in Rich Internet (RIA) 2, 17, 92, 218, 237
Applications 5 query string 221, 227, 274
Observable 92 quirks mode 161 S
options hash 192
progressive disclosure R Safari 155, 160, 247
113 problems loading scripts
repetitiveness 186 read-only status, applying 181
responsibilities and 5 201206 scripts, dynamic loading 180
structure and 4 ready handler 165 183
346 INDEX
scroll() 102 string trimming 168 droppableDestroy() 314
scrollbars 288 styles, setting 6167 droppableDisable() 315
scrolling dimensions 287289 styling 5868 droppableEnable() 315
scrollLeft() 287 submit() 102, 107 droppables 308315
scrollTop() 287 submitting forms Droppables Lab 311
select() 102, 107 Ajax 276284 magnify 316
selecting check boxes 27 subsettting wrapped sets 42 mouse interactions 300315
selectors 3, 6, 1730, 258 43 required files 301
attribute 20, 2224 resizables 315
basic 1920 T selectables 315
child 2024 slider 316
container 20, 2324 Termifier, The 259 sortables 315
CSS syntax 17 test-driven development table 316
custom 2730 208 tabs 316
filter 29 text() 69 UI Draggables Lab 304
find 29 this 330334 widgets 316
form-related 29 thumbnail images 206 UI principles
inverting 2930 timers 83 gradual transition 135
nesting 23 title attribute 258, 261 progrssive disclosure 128
positional 2427 toggle() 108, 134137 unbind() 103, 295
regular expression syntax toggleClass() 59 United States Postal Codes
22 toggling display state 134 172
relational 2024 Tomcat web server 225 unload() 102
XPath plugin 30 tooltip 258 Unobtrusive JavaScript 3, 87,
Selectors Lab 17 top-level flags and functions 115, 230, 292
self-disabling form 57 154 practical application 209
semantic actions 83, 106 translating data 173 unsuccessful form elements
serialize() 227 translation 172176 79
serializeArray() 228 Trash 300 uploading via Ajax 284
serializeForm() 276 trigger() 106 URI encoding 221, 227
server setup 225 trimming 168 URL 221, 227
server-side encoding 272
resources 225 U user agent detection 155161
state 248 user interface, annoyances 49
templating 230 UI Draggables Lab 304305 utility functions 8, 154
servlet 225 UI Droppables Lab 311313
setting width 63 UI Plugin 299316 V
show() 127, 136 accordian 316
siblings() 43 calendar 316 val() 7980, 231, 270
size() 34 dialog 316 variables as part of closure
slice() 42 download location 300 335
slideDown() 143 draggable() 300 viewport scrolling 287
slideshows 206209 draggableDestroy() 303
slideToggle() 144 draggableDisable() 304 W
slideUp() 144 draggableEnable() 304
sniffing 155161 draggables 300308 W3C 159
spoofing 155 drop shadow 316 box model 161
stop() 145 drop zones 312 W3C DOM Specification 84
strict mode 161 droppable() 308 Wastebasket 300
INDEX 347
web server 225 obtaining elements from XML 236, 277
width and height 64 3436 XML DOM 223
width() 6364, 285 removing elements 3942 XMLHTTP 218
wiki 57 subsetting 4243 XMLHttpRequest (XHR) 218
window Wrapped Set Lab 33 instance creation 219
origin 289 wrapper 7 instantiating 219
properties 325 wrapper methods making the request 221222
scrolling 288 applying multiple opera- methods and properties
window.event 87, 97, 104 tions 201206 219
window.setInterval() 335 defining 199216 ready state handler 221
window.setTimeout() 329 implementation functions responses 223224
wrap() 75 212214 responseText 223
wrapped set 7, 32, 4344 mainaining state 210 responseXML 223
adding elements 3639 status 222
as array 34 X XPath selectors plugin 30
augmenting 3643
determining size 34 X11 83 Z
filtering 40 XHR. See XMLHttpRequest
iterating over 51 (XHR) zebra-striping 2
manipulation 32 XHTML 53 ZIP Codes 172