INDEX

SYMBOLS

$() shortcut for jQuery() function 296, 299, 313, 361

$() conflicts with other scripts that use $() 361

$(document).ready(function(){…}) 312

$(function() { … }) (shortcut) 313, 3645

$(this) 324, 549

[] Array syntax 72

[] Accessing an object's properties 103

{} Code blocks 57

{} Code block (function) 90

() Final parentheses (calling a function) 97

() Grouping operator 97

= Assignment operator 107

+= Operator (adding to a string) 111, 125

== Equal to (comparison operator) 150, 168

=== Strict equal to (comparison operator) 150, 168

!= Not equal to (comparison operator) 150, 168

!== Strict not equal to (comparison operator) 150, 168

> Greater than (comparison operator) 151

>= Greater than or equal to (comparison operator) 151

< Less than (comparison operator) 151

<= Less than or equal to (comparison operator) 151

&& Logical and (logical operators) 157, 158, 537

! Logical not (logical operators) 157, 159

|| Logical or (logical operators) 157, 159, 169

. Member operator 50, 103

// (No http: in a url) 355

A

.abort() method (jqXHR object) 389

Accessibility 46, 491

Accordion 430, 4925, 5225

.accordion() (jQuery UI method) 430

action (DOM property – forms) 572

add() (option to select box) 584

.add() (jQuery method) 531

.addClass() (jQuery method) 320, 498, 5123, 519, 565

addEventListener() (DOM method) 2545, 5701

Adding or removing HTML Content

Comparing techniques 2267

innerHTML & DOM manipulation 218225, 2401

Using jQuery 3149, 3467

Addition 767, 181

.after() (jQuery method) 3189

Age verification 6179

Ajax

Introduction to 3703

Data formats

HTML 374, 3789, 3901

JSON 374, 3767, 3823, 3967

XML 3745, 3801

Forms 3945

.serialize() (jQuery method) 394

jqXHR object (see J > jqXHR object)

JSON object (see J > JSON > JSON object)

Relative URLs 389

Requests (loading data):

CORS (Cross Origin Resource Sharing) 384

HTML 3789

HTML (jQuery) 3901, 393

JSON 3823

JSON/JSONP from a remote server 3858

Proxy for loading remote content 384

XML 3801

jQuery 3889, 3923

.load() 3901, 407, 427

$.ajax() 388, 3989, 405

$.get() 3923

$.getJSON() 392, 3967

$.getScript() 392

$.post() 392, 3945

Responses 373391

Update URL 4247

URLs (maintaining) 4247

XMLHttpRequest object

Methods

open(), send() 3723

Properties

responseText 379, 383, 389

responseXML 3802, 389

status 373, 3789, 389

XDomainRequest object (IE8–9) 384

Alert box 125

alert() (window object) 1245

.always() (jqXHR object) 389, 3967

AngularJS 428, 4349

.animate() (jQuery method) 332, 3345, 3523, 493, 515, 5201

Anonymous functions 88, 96

APIs

Introduction to 410, 412

API Keys 441

Console API 470

HTML5 APIs 413

Geolocation API 4169

History API 4247

Web Storage API 4203

Platform APIs 440

Google Maps API 4417

Scripts

Introduction to 428

AngularJS 4349

jQuery UI 429433

.append() (jQuery method) 318, 565

.appendTo() (jQuery method) 318, 505, 519

appendChild() (DOM method) 222, 240

Arguments 93, 109

Arithmetic operators 767

Arrays

Introduction to 703

Adding and removing items 530, 5367, 5403

Creating 72

split() method (String object) to create arrays 128130, 5467, 563, 6189

Looping through an array 1745, 535

Methods

concat() 530

every() 530

filter() 530, 5367

forEach() 530, 5367

map() 530

pop() 530

push() 530, 5367, 5403

reverse() 530, 5645

shift() 530

some() 530

sort() 530, 5549, 5645

unshift() 530

Properties

length property 72, 1189

Arrays and objects

Arrays are objects 1189

Array-like objects (jQuery) 308, 340

Arrays of objects 119, 5335

Multiple return values from a function 95

vs variables and objects 1167

Assignment operator 61, 107

Asynchronous loading (images) 509

Asynchronous processing 371

attachEvent() (IE8 event model) 255, 2589, 5701

Cross-browser solution 5701

Attributes

.attr() (jQuery method) 3201

Creating / removing (DOM method) 2325

Autocomplete (live search) 370

B

back() (history object) 426

.before() (jQuery method) 318

beforeunload event 2867

Behavior layer 44

Binding events 248, 250

blur() (DOM method) 573

blur event 247, 2745, 282, 573, 5889

Boolean data type 62, 66

break keyword 174

Browsers

Developer tools

Debugging 4647

Examining DOM 2367

Dimensions 1245, 350

Feature detection (see F > Feature detection)

JavaScript console 46479 (see also C > Console)

Rendering engine 40

Scrollbars 350

Support in examples 10

Browser Object Model

Introduction to 1212

history object 122, 1245, 4247

location object 122

navigator object 122

screen object 122, 1245

window object 122, 1245

Bubbling (event flow) 2601

Builtin objects 1207

:button (jQuery selector) 342

C

Caching

Cross-references 5401

DOM queries 1901, 575

Images (in custom object) 509511

jQuery selections 3089, 5401

Object references 5401

Calling a function 91

cancelable property (event object) 262

Capturing (event flow) 2601

Case sensitivity 56

catch (error handling) 4801, 5767

CDN 3545

ceil() (Math object) 134

Centering images 511

Chaining (jQuery methods) 311

change event 247, 282, 573, 5767, 5867

Character count 5889

charAt() (String object) 128130

Checkboxes 5801

:checkbox (jQuery selector) 342

:checked (jQuery selector) 342

checked (DOM property – forms) 573, 5801

.children() (jQuery method) 336

clearTimeout() (window object) 5179

.click() (jQuery method) 5123

click() (DOM method) 573

click event 39, 246, 2767, 573

clientX, clientY (event object) 2789

.clone() (jQuery method) 3467

.closest() (jQuery method) 336

Code blocks 56, 90

Code dependencies 616

Code reuse 616

Collections

elements (nodeLists) 1969

elements (form) 572, 600

Color picker 591

Comments 57

Compare functions (sorting) 5559

Comparison operators 1509

Checking equality 168

Comparing expressions 1545

Operands 152

Truthy and falsy values 167

concat() (array object) 530

Conditional loading 5967

Conditional statements 149

if 1601, 181

if … else 1623

switch 1645, 291

Conditions (loops) 1701

Console

Breakpoints 4768

console.assert() 475

console.error() 472

console.group() 473

console.groupEnd() 473

console.info() 472

console.log() 4701

console.table() 474

console.warn() 472

debugger keyword 479

Constructor notation 106111, 113

:contains() (jQuery selector) 338

Content layer 44

Content panels

Accordion 4925, 5225

Modal window 5005

Photo viewer 506513

Slider 515520

Tabs 4969

continue keyword 174, 5945

Coordinates (geolocation API) 4179

copy event 247

CORS (Cross Origin Resource Sharing) 384

Create attributes (DOM) 234

Create elements (DOM) 126, 2223, 240

Create text nodes (DOM) 126, 2223, 240

Cross-Site Scripting (XSS) Attacks 228231

.css() (jQuery method) 3223, 5045, 5101, 521

CSS

Box dimensions 348

CSS-style selectors in jQuery 3023

Properties and values 9

Selectors to find elements (DOM) 193, 197, 202

Updating class names 189, 195, 232

Updating id attributes 189, 232

Updating styles (DOM) 195, 232

Updating styles (jQuery) 3203, 4979

Cut, copy, paste element (jQuery) 3467

cut event 247

D

.data() (jQuery method) 5467, 565, 602, 6089

data-* attributes (HTML5) 28990, 5446, 608

Data binding (Angular) 437

Data models

Introduction to 267

Comparing techniques 1167

Arrays and objects 1189, 533

Objects and properties 28, 1025, 142

Data types

Complex data types

Objects (Arrays and functions) 131

Simple (primitive) data types

Boolean 62, 131, 167

Number 62, 1315

Null 131

String 62, 128130, 131

Undefined 131

Type coercion and weak typing 1667

Dates / Date object

Introduction to 1369

Comparing 6189

Creating / Constructor 136, 138, 143

Date formats 1369

Date pickers 4323, 591, 6189

Day & month names 137, 143

Difference between two dates 139, 143

Sorting 559, 5623

Methods

getTime(), getMilliseconds(), getSeconds(),

getMinutes(), getHours(), getDate(), getDay(),

getMonth(), getFullYear(),

getTimeZoneOffset() 137

setTime(), setMilliseconds(), setSeconds(),

setMinutes(), setHours(), setDate(),

setMonth(), setFullYear(), toString(),

toTimeString(), toDateString() 137

dblclick event 246

Debugging

Errors and a debugging workflow 4623

Tips 484

(see also Console and Troubleshooting)

Declare a variable 601

Declaring an array 713

Declaring a function 90, 92

defaultChecked (DOM property – forms) 573

defaultValue (DOM property – forms) 573

Delays

clearTimeout() 5179

.delay() (jQuery method) 311, 3323, 364

setTimeout() 5179

Delegating events 26670, 2901, 331

delete keyword 107, 112, 533

Deserializing JSON data 3823

Design patterns 501

.detach() (jQuery method) 346, 5023, 505

Developer tools 2367, 4645

:disabled (jQuery selector) 342

disabled (DOM property – forms) 573, 578

disabled (JavaScript is disabled) 491

document object

Introduction to 369, 123, 1267

Events

load 39, 246, 2723

Methods

getElementById() 39, 126, 193195

createElement(), createTextNode() 126, 2223

querySelectorAll() 126, 193, 197, 202, 2045

write() 39, 49, 126, 226

Properties

domain 126

lastModified 36, 39, 1267

title 36, 39, 1267

URL 1267

DOMContentLoaded event 2867

DOM (document object model)

Introduction to 121, 1267, 184, 1867

Elements

Accessing

getElementById() 1935

getElementsByClassName() 193, 1979, 200

getElementsByTagName() 193, 197, 201

querySelector() 1934, 2023

querySelectorAll() 193, 197, 2023, 2045

Adding

appendChild() 2223

insertBefore() 222, 240

Creating

createElement() 2223

Updating

DOM manipulation 219, 2225, 227

innerHTML 218, 2201, 227, 22831

textContent and innerText 216

Attributes

class attribute/className property 195, 232

getting and updating 2325

id property 232

Text nodes

createTextNode() 222

nodeValue 2145

textContent and innerText 2167

Document nodes 186

document object (see D > document object)

DOM queries

Performance (fastest route) 192

Caching DOM queries 1901, 575

DOM tree

Introduction to 401, 1867

Inspecting (exploring – browser tools) 2367

Traversing the DOM 208, 21011

Updating 2123

Events (see E > Events)

Event handlers 250, 2523

Event listeners 250, 2545, 263, 265

Nodes 40, 1869

Whitespace 209211

NodeList 192, 1969, 202205

length property 196

Live and static NodeLists 196

Looping through 2045

Selecting items from a NodeList 1989

.done() (jqXHR object) 389, 405

Dot notation 103 (see also member operator)

Do while loops 170, 177

Dropdown boxes 5847

DRY principle (don't repeat yourself) 616

Dynamic filtering 53843

E

.each() (jQuery method) 3245, 333, 339, 4989, 519, 531, 5467

ECMAScript 532

Elements (see D> DOM > Elements and J > jQuery)

Dimensions (jQuery) 3489

Finding elements (DOM) 192203

Finding elements (jQuery) 296, 3023, 336, 342

Form element content (jQuery) 3425

Hiding/showing 3323, 5823, 6189

Inserting new elements (jQuery) 3189

Updating elements (DOM) 2123

Updating elements (jQuery) 313

elements collection (DOM property) 572, 5745

.empty() (jQuery method) 346, 5045

:enabled (jQuery selector) 342

.eq() (jQuery method) 3401, 5123, 521

Equality 1501, 168

equals sign (assignment operator) 61

Errors

Common errors 4601, 485

Debugging workflow 4623 (and tips 4845)

error event 246, 272

Error handling 4801, 5767

Error objects 459, 461, 481

EvalError 459460

RangeError 459, 461

ReferenceError 45960

SyntaxError 45960

TypeError 459, 461

URIError 45960

Exceptions 458, 4801

NaN 461

Understanding errors 458

e (shorthand: event or error object) 328

EvalError 459460

Evaluating conditions 14959

Events

Introduction to 5, 3031, 24450

All events

beforeunload 2867

blur 247, 2745, 282

change 2823, 5867

click 2601, 2689, 2767

dblclick 246, 276

DOMContentLoaded 2867

DOMNodeInserted 284, 285

DOMNodeInsertedIntoDocument 284

DOMNodeRemoved 284

DOMNodeRemovedFromDocument 284

DOMSubtreeModified 284

error 246, 272

focus 2745, 282, 5889, 5945

focusin 274

focusout 274

hashchange 286, 4267

input 247, 271, 2802, 5523, 573, 5889

keydown 280

keypress 2801

keyup 280

load 39, 246, 2723

mousedown 276

mousemove 276, 279

mouseout 276

mouseover 276

mouseup 276

resize 272, 5045

scroll 272

submit 2823, 572, 5745

unload 272

binding 248, 250

Delegation (DOM) 266, 26871, 2901

Delegation (jQuery) 3301, 365

Determining position 2789

Event flow (bubbling and capturing) 2601

Event handlers

Cross browser 5701

DOM Event handlers 250, 2523

DOM Event listeners 250, 2545

Removing event listeners 255

Using parameters with events 2567, 263

HTML event handlers 2501

event object DOM 2623, 26570

Methods

preventDefault() 262, 267, 283

stopPropagation() 262, 267

Properties

cancelable, clientX, clientY, pageX, pageY,

screenX, screenY, target, type 262, 2789

event object (jQuery) 3289, 331

Methods

.preventDefault() 328

.stopPropagation() 328

Properties

data, pageX, pageY, target, timeStamp,

type, which 328

IE8 event model

attachEvent() 255, 2589, 290

Cross-browser helper function 5701

event object 2645, 5701

Property and method equivalents 262

Fallback example 2589

jQuery (consider as alternative) 3001

jQuery events 326331, 343

Performance (delegation) 266, 2689, 290, 331

Terminology (fired, raised, triggered) 247

Types of event 2467, 271

W3C DOM 271286

HTML5 2867

jQuery events 326331, 3435

Which element user interacted with 26270

every() (array object) 530

Exceptions (see Errors)

Execution contexts 4536

Expressions 746

Comparing expressions 154

Function expressions 967

F

.fadeIn() (jQuery method) 298, 311, 3327, 365

.fadeOut() (jQuery method) 3323, 337, 51011

.fadeTo() (jQuery method) 51011

.fail() method (jqXHR object) 389, 3967, 405

Falsy and truthy values 1679

Feature detection

Feature detection (in jQuery) 301

Modernizr 4145, 417, 419, 593, 5967

:file (jQuery selector) 342

File extension

.js 46

.min.js 298

Filtering

Introduction to 534

filter() (array object) 530, 5367

.filter() (jQuery method) 3389, 343, 531, 5489

Tags 5449

Text / live search 5503

finally (error handling) 4801

Final parentheses 97

.find() (jQuery method) 3367, 5189, 5645

Firebug 237

firstChild (DOM property) 1889, 2089, 211

Flags 5789

floor() (Math object) 1345, 139

Flowcharts 18, 23, 148, 494

fn object (jQuery) 5235

focus() (DOM method) 273, 573

.focus() (jQuery method) 326, 619

:focus (jQuery selector) 342

focus event 2745, 282, 573, 5889

focusin event 247

focusout event 247

forEach() (array object) 530, 5367, 5423

for loop 1723, 175, 207

Forms

Controls (types of) 573

Changing type of form control 5767

Checkboxes 5801

Date picker (HTML5) 591

Date picker (jQuery) 4323, 6199

Email 590, 611

Radio buttons 5823

Range inputs 591

Select boxes 5847

Submit button 5789

Text input 5767, 5945

Textareas 5889

elements collection 600

Enhancement

Introduction to 568

jQuery UI (Date picker & slider) 4323

Password length and match 6201

Show or hide based on other form input 6189

Giving focus to an element 273, 326, 573, 619

Methods 343, 5723, 584

Properties 343, 5723, 584

Submitting forms 5745, 5789

Validation 282, 598619

Introduction to 568, 598

Age 6179

Character count 5889

Checkbox selected 5801

Checking for a value 6067

Checking length of text input 615

Dates 6179

Email 611

HTML5 form validation 5901, 6045

Length of text/password input 5889, 6201

Numbers 132, 343

Password length and match 615

Radio button selected 5823

Regular expressions 6123

Required elements 6067

test() and regular expressions 6113

Turn off HTML5 validation 591

URL 590

Which element the user interacted with 5767 (see also Event object)

forward() (history object) 426

Function-level scope 98

Functions

Introduction to 889

Anonymous functions 88

Arguments 923

Calling 91, 93

Code block 90

Declaring 90, 92, 96

Final parentheses 97

Function expressions 967

Helper functions 570571

initialize / init() 539, 5423

Parameters 88, 923

return 92, 947, 5789, 5867, 5945

this (scope of keyword) 270 (see also this keyword)

G

Geolocation API 4169

$.get() (jQuery method) 388, 3923

getAttribute() (DOM method) 2323

getCurrentPosition() (Geolocation API) 4179

getDate() (Date object) 137

getDay() (Date object) 137

getElementById() (DOM method) 126, 1925

getElementsByClassName() (DOM method) 193, 197, 200

getElementsByTagName() (DOM method) 193, 197, 201, 240

getFullYear() (Date object) 1378

getHours() (Date object) 137

getItem() (storage API) 4213

$.getJSON() (jQuery method) 388, 392, 3967, 405

getMillseconds() (Date object) 137

getMinutes() (Date object) 137

getMonth() (Date object) 137

$.getScript() (jQuery method) 388, 392

getSeconds() (Date object) 137

getTime() (Date object) 137

getTimezoneOffset() (Date object) 137

Global JavaScript Objects

Introduction to 121, 124139

Boolean object 123

Date object 123, 1369

Math object 123, 1345

Number object 123, 1323

Regex object 123

String object 123, 128130

Global scope 98

go() (history object) 426

Google Maps API 4417

Grouping operator 97

:gt() (jQuery selector) 3401

H

:has() (jQuery selector) 3389

hasAttribute() (DOM method) 2323, 235

.hasClass() (jQuery method) 365

hashchange event 286, 4267

.height() (jQuery methods) 3489, 350, 353

height (screen object) 1245

Helper functions 570571

.hide() (jQuery method) 3323, 5123, 5823, 6189

History API 4247

history object (Browser Object Model) 1245, 4247

Methods

back(), forward(), go(),

pushState(), replaceState() 426

Properties

length 426

History stack 424

Hoisting 456

How many characters in a string 128130

.html() (jQuery method) 3147

HTML5

APIs 413

Geolocation API 4169

History API 4247

Web Storage API 4203

Attributes

data-* attributes 28990, 5446, 608

required 591, 607

Events 2867

Form controls (support, polyfills, styling) 5902

placeholder fallback 5947

I

id (DOM property) 189, 232

if … else 1489, 1623

if statements 1489, 1603, 181

:image (jQuery selector) 342

Images centering 511

Immediately Invoked Function Expressions (IIFE) 97, 142, 504, 523

Implicit iteration 310

Increment in loops 1703

.index() (jQuery method) 565

Index numbers 129

indexOf() (String object) 128130, 5503

Initialize / init() (functions) 539, 5423

Inline scripts 49

.innerHeight() (jQuery methods) 348

innerHeight (window object) 1245

innerHTML (DOM property) 218, 2201, 227

Security risks 228

innerText (DOM property) 2167

.innerWidth() (jQuery methods) 348

innerWidth (window object) 1245

:input (jQuery selector) 342

input event 247, 271, 2802, 5523, 573, 5889

insertBefore() (DOM method) 240

Instances (of objects) 10911

Interpreter

Definition 40

How it works 4527

.is() (jQuery method) 343, 521, 565

isNaN() (Number object) 132

$.isNumeric() 343

item() (Array) 71

item() (NodeLists) 196, 198

J

JavaScript console 46279

JavaScript History / Standards 532

JavaScript libraries 3601, 428

JavaScript not enabled 491

jQuery

Introduction to 294, 296, 2989

$() shortcut for jQuery() 296, 299, 313, 361

$(function() { … }); 313

Advantages 300

Ajax (see Ajax)

API 358

Caching selections 3089

Chaining methods 311

Conflicts with other scripts 361

document.ready() 31213

Documentation 358

Elements 3023, 3146, 3189, 3369, 3427

Events object 326331

.fn object 5235

Forms (.serialize()) 394

Global methods

$.ajax() 388, 3989, 405

$.get() 388, 3923

$.getJSON() 388, 392, 3967, 405

$.getScript() 388

$.isNumeric() 343

$.post() 388, 3945

How to include 298, 3545

Implicit iteration 310

jQuery() function (see also $()) 296, 299, 313, 361

jQuery methods: full list of methods 3045

jQuery selection (matched set) 2967, 306

Adding to / filtering selection 338341

Caching 3089

Number of elements (length property) 364

jQuery selectors 296, 300, 3023

jQuery Selectors: full list of selectors 3023

jQuery UI 429

Accordion 430

Date picker 43233, 6189

Form enhancements 4323

Tabs 431

Looping

Through elements (implicit iteration) 310

Through elements .each() (see E > .each())

Matched set (see J > jQuery > jQuery selection)

Page is ready to work with 3123

Plugins 359, 428

Creating your own 5225

Date picker 619

jQuery UI 429434, 6189

noUISlider 538

Versions 298, 301

Where to get / download 298, 3545

Where to place script 313, 3547

jqXHR object 389, 405

Methods

.abort(), .always(),

.done(), .fail() 389, 3967

.overrideMimeType() 405

Properties

responseText, responseXML,

status, statusText 389

JSON

Introduction to 3767

As an Ajax data format 374

Debugging JSON 474

Displaying JSON 3823

JSON object

parse() & stringify() methods 377, 3823

Serializing and deserializing data 3823

JSONP 3857

K

Keyboard events 2467, 2801

keydown, keypress, keyup, input event 2467

keys (objects) 101, 533, key/value pairs 118

Keywords

break 1645, 174

case 1645

catch 4801, 5767

continue 174, 595

debugger 479

delete 107, 112, 533

finally 4801

new (array) 71

new (object) 106, 109

return 92, 947, 5789, 5867, 5945

switch 1645

this 1029, 1145, 270, 324

throw 482

try 4801, 5767

var 60, 638

L

lastChild (DOM property) 208, 211

lastIndexOf() (String object) 128130

length (history object) 124, 426

length (items in a select box) 584

length (String object) 128130, 5889, 6201

Length of text input 5889

Lexical scope 457

Lexicographic sort 554

Libraries 3601, 428

Linking to a JavaScript file 47, 51, 298, 313, 3547

Links

Get value of href attribute 407

Which link was clicked 4989

Literal notation 102, 1045, 113, 142

(see also O > Objects > Creating your own objects)

Livesearch (autocomplete) 370

load event 246, 2723, 2867

.load() (jQuery method – Ajax) 388, 3901, 407

Local scope 989 (see also p4567)

Locale 137

localStorage 4203

location property (window object) 1245

Logical operators 1569, 169

Logical and 1578, 537

Logical not 157, 159

Logical OR 157, 159

Short-circuit evaluation 157, 169

Looking for text 5503

Loops

Introduction to 1707

break keyword 174 (see also Keywords > break)

Conditions 1703

continue keyword 174, 595

Counters 1714, 181

do while loop 170, 177

for loop 175

Introduction to 170, 175

Diagram 1723

Looping through elements 2047

Increment (++) 171

Infinite loop 174

jQuery implicit iteration 310

jQuery .each() method 324

Looping through

an array 175, 530, 5347, 5423

checkboxes 5801

DOM elements (nodeList) 2047, 5945

properties of an object 533, 605

radio buttons 5823

Performance 174

while loop 170, 176, 181

Lowercase 128130

:lt() (jQuery selector) 340

M

map() (array object) 530

Maps (Google maps) 4417

Matched set (jQuery) 2967, 3069, 33841, 364

Math object 1345

Methods

ceil(), floor(), random(),

round(), sqrt() 134

Properties

PI 134

Member operator 50, 103

method property (DOM property – forms) 572

Methods

Introduction to 323, 10011

Calling a method 50, 103

Minification (.min.js extension) 298

Modal window 5005

Modernizr 4145, 417, 419, 593, 5967

Module pattern 501

mousedown, mousemove, mouseout,

mouseover, mouseup event 246, 2767

multiple (DOM property – forms) 584

Multiplication 767, 1767, 181

Mutation events 247, 2845

MVC / MV* 360, 4349

N

name (DOM property – forms) 5723

Name/value pairs 28, 889, 101, 113, 1168, 131

Naming conflicts (collisions) 97, 99, 361

NaN 78, 132, 461, 483

navigator object (Browser Object Model) 122, 414, 4179

new keyword 71, 106, 109

.next() (jQuery method) 3367, 495

.nextAll() (jQuery method) 336

nextSibling (DOM property) 208, 210, 214

NodeLists 1969

Nodes (introduction to) 40, 1867

nodeValue (DOM property) 184, 2145, 241

No JavaScript 491

Nonblocking processing 371

.not() (jQuery method) 338, 4945, 531

:not() (jQuery selectors) 3389

noUiSlider 538, 5423

novalidate property (HTML5 forms) 591, 6045

Number object (Built-in Objects)

Methods

isNan(), toExponential(),

toFixed(), toPrecision() 1323

Rounding numbers 1323

Numbers 623

Random numbers 135

Rounding 1323

Sorting 558

Numeric data type 62 (see also D > Data types)

O

Objects

Introduction to 269, 345, 1001

Accessing properties and methods

Dot notation 1035, 110

Square brackets 103, 107

Adding and removing properties 112

Arrays and objects 1189, 308, 340, 533

Builtin objects 1203

Creating

Comparison of techniques 113

Constructor notation 106, 108111, 113

Literal notation 102, 1045, 113, 142

Instances of 10911

Multiple objects 105, 108111

Creating your own objects (examples of)

Compare functions for sorting 5623

Custom object for valid elements 601, 6045

Data: cameras and projectors 5867

Data: people for filtering 5334

Image cache 50913

Modal window 5015

Tags 5449

keys 1012, 113, 1178, 131, 533

Methods 325, 389, 10011

Properties 289, 345, 10012

this 1145

Updating properties 107

vs variables and arrays 1167

Object models (introduction to) 121

.off() (jQuery method) 505

.offset() (jQuery methods) 351, 353

.on() (jQuery method) 32631, 3435, 365

onpopstate property (window object) 4267

.open() (XMLHttpRequest object) 373, 379, 381, 383

Operators

+= adding to a string 111, 125, 127, 130, 133

Comparison operators 14856

> greater than, >= greater than or equal to 1515

() grouping operator 97

< less than, <= less than or equal to 151

. Member operator 50, 103

== is equal to, != is not equal to 150

=== strict equal to, !== strict not equal to 150

? : Ternary operator 562, 579, 583

Unary operator 168

<option> elements 5847

options (DOM property – forms) 584

Order of execution 452

.outerHeight(), (jQuery method) 348

.outerWidth() (jQuery method) 348

.overrideMimeType() (jqXHR method) 405

P

Page loads – run script 273, 3123

pageXOffset, pageYOffset (window object) 1245

pageX, pageY (window object) 124, 2789

Parameters 50, 88, 923

With event listeners 2567

.parent() (jQuery method) 336, 4989

.parents() (jQuery method) 336

parentNode (DOM property) 208, 2245

:password (jQuery selector) 342

paste event 247

Performance

Caching

DOM queries 1901, 575

Images (custom object) 50911

jQuery selections 3089, 5401

Object references 5401

Text (custom object) 551

Event delegation 266, 26871, 2901, 3301, 365

Global vs Local variables 989

Selecting class and id attributes (jQuery vs DOM) 324

Where to place scripts 3567

PI property (Math object) 134

placeholder (and its fallback) 5901, 5945

Polyfills 5937

pop() (array object) 530

.position() (jQuery method) 351

Position object (geolocation API) 4189

PositionError object (geolocation API) 4189

Position of items on page 3513

$.post() (jQuery method) 388, 392, 3946

.prepend() & .prependTo() (jQuery methods) 318

Presentation layer 44

preventDefault() (event object) 262, 267, 283,

.preventDefault() (jQuery method) 328, 345, 365, 4945, 5045

previousSibling (DOM property) 20810

Primitive data types (see Data types)

Progressive enhancement 45

.prop() (jQuery method) 6189

Properties 289, 345, 10012

Protocol relative URL 355

Proxy (Ajax) 384

push() (array object) 519, 530, 5367, 540, 5423

pushState() (history object) 4247, 426

Q

querySelector() (DOM method) 1936, 202, 241

querySelectorAll() (DOM method) 126, 193, 197

R

:radio (jQuery selector) 342

random() (Math object) 1345

Random numbers 135

RangeError 459, 461

Range slider 4323, 538, 5423

.ready() (jQuery method) 3123, 361, 364

Reference

To an element DOM 1901, 575

To an element jQuery 3089, 5401

To an object 5401

ReferenceError 45960

Regular expressions 563, 6113

Relative URLs (Ajax) 389

Removing content:

.remove() (jQuery method) 299, 3167, 346, 584

.removeAttr() (jQuery method) 320

removeAttribute() (DOM method) 232, 235

removeChild() (DOM method) 2245

.removeClass() (jQuery method) 3201, 339, 341, 5123

removeEventListener() (DOM method) 255

(see also innerHTML an(d detach())

replace() (String object) 128130, 4067, 5623

replaceState() method (history object) 4246

.replaceWith() (jQuery method) 316

Require.js 593

:reset (jQuery selector) 342

reset() (DOM method – forms) 572

reset event 247, 572

resize event 246, 272, 5045

responseText (XMLHttpRequest object) 379, 383, 389

responseXML (XMLHttpRequest object) 380, 389

return keyword 92, 947, 5789, 5867, 5945

reverse() (Array object) 530, 5645

RangeError 459, 461

Rounding numbers 1325

round() (Math object) 134

S

Same origin policy 420

Saving a script 46

Scope 989, 457

Global scope 989, 4537

IIFEs 97

Lexical scope 457

Local (function-level) scope 989, 453

Naming collisions and namespaces 99, 523

Screen dimensions 124125, 278, 350

screen object (Browser Object Model) 1245

Properties

height, width 124

screenX, screenY (window object) 124, 278

<script> element 47

Conditional loader for scripts 596597

When to load 5967

Where to place <script> tag 48, 51, 313, 3547

Scripts

Approach to writing 1623

Definition 147

scroll event 246, 272

.scrollLeft() (jQuery method) 350

.scrollTop() (jQuery method) 350, 353

Search 550553

Security: Cross Site Scripting (CSS) Attack 228231

Select boxes 5847

select() (DOM method) 573

:selected (jQuery selector) 342

selected (DOM property – forms) 573, 5803

selectedIndex (DOM property – forms) 584

selectedOptions (DOM property – forms) 584

select event 247

send() (XMLHttpRequest object) 373, 379, 381, 383

Separation of concerns 490

.serialize() (jQuery method - forms) 3945

Serializing JSON data 382

sessionStorage 4203

setAttribute() (DOM method) 232, 234

setDate() (Date object) 137

setFullYear() (Date object) 137

setHours() (Date object) 137

setItem() (storage API) 4213

setTime() (Date object) 137

setTimeout() (window object) 5179

setMillseconds() (Date object) 137

setMinutes() (Date object) 137

setMonth() (Date object) 137

setSeconds() (Date object) 137

shift() (array object) 530

Shortcircuit evaluation 157, 169

.show() (jQuery method) 3323, 344, 364

.siblings() (jQuery method) 336, 5489

Slider (content panel) 515520

.slideToggle() (jQuery method) 4945

some() (array object) 530

sort() (array object) 530, 533, 55465

Sorting 5556

Dates 559

Lexicographic sort 554

Numbers 554, 558

Random order 558

Sorting a table 5616

split() (String object) 128130, 5467, 563, 6189

sqrt() (Math object) 134

src attribute 47

Stack 4545

Statements 56

.stop() (jQuery method) 332, 353, 5101

stopPropagation() (DOM event object) 262, 267

.stopPropagation() (jQuery method) 328

Storage objects (storage API) 4203

Storing data (compare techniques) 1167

String data type 62, 645

Checking for text 5523

String object

Methods

charAt(), indexOf(), lastIndexOf(),

replace(), split(), substring(), trim(),

toLowerCase(), toUpperCase() 128130

Properties

length 128130

:submit (jQuery selector) 342

submit() (DOM method – forms) 572

Submit buttons 5789

submit event 247, 271, 282, 572

substring() (String object) 128130

.complete() (jQuery method) 396

.error() (jQuery method) 396

.success() (jQuery method) 396

switch statements 164165, 291

Switch value 165

Synchronous processing 371

SyntaxError 459460

T

Tables

Adding rows 5423

Sorting a table 5605

.tabs() (jQuery UI method) 431

Tabs 431, 4969

target property (event object) 2623, 2689

Templates 360, 4349

Ternary operator 5623, 579, 583

Testing for features (see Feature detection) test() method 611

.text() (jQuery method) 3147, 3645, 535

:text (jQuery selector) 342

<textarea> 5889

textContent (DOM property) 2167

this 1029, 1145, 270, 324

throw (error handling) 4813

Timers (see Delays)

.toArray() (jQuery method) 531

toDateString() (Date object) 137

toExponential() (Number object) 132

toFixed() (Number object) 132

.toggle() (jQuery method) 332, 493

.toggleClass() (jQuery method) 565

toLowerCase() (String object) 128130, 5503

toPrecision() (Number object) 132

toString() (Date object) 137

toTimeString() (Date object) 137

toUpperCase() (String object) 128130, 406

Traversing the DOM 20811

trim() (String object) 128130, 5523

Troubleshooting

Ajax not working in Chrome (locally) 378

Ajax requests: assets not showing up 389

Common errors 485 (see also 4601)

Console 464474

Debugging JSON data and objects 474

Debugging tips 4623, 484

Equivalent values do not match 166

Events firing more than once 2601

IE will not run script locally 47

jQuery object only returns data from first element in selection 307

NaN 78, 461

try … catch 4801, 5767

Truthy and falsy values 1679

try (error handling) 4801, 5767

type (DOM property – forms) 573

type (event object) 262

Type coercion 166, 168

TypeError 459, 461

U

UML (Unified Modeling Language) 494

undefined 61, 485

Unix time 1367

unload event 246, 272 (see also beforeunload)

unshift() (array object) 530

Untrusted data (XSS) 22831

.unwrap() (jQuery method) 346

Updating content (see DOM and jQuery)

Updating page without refreshing (see Ajax)

Uppercase 128130, 406

URIError 459460

URL (get current) 369, 124

V

.val() (jQuery method) 343, 345, 365, 5423

Validation (definition) 282, 568

value (DOM property – forms) 573, 5745, 5789

Variables

Assign a value / assignment operator 61

Declaration 60

Definition 589

Naming 60, 69

Naming conflicts and collisions 97, 99

Scope 98, 453

undefined 61, 485

vs arrays and objects 1167

var keyword 60, 638

W

Weak typing 1667

Web Storage API 4203

Where to place your scripts 356

while loop 170, 176, 181

Whitespace (DOM) 209211, 237

width (screen object) 1245

.width() (jQuery methods) 34850

window object (Browser Object Model) 367, 1245

Introduction to 367

Methods

alert(), open(), print() 124

Properties

innerHeight, innerWidth 1245

location property 36, 124

onpopstate 426

pageXOffset, pageYOffset 124

screenX, screenY 1245

write() (document object) 126, 226

XYZ

XDomainRequest object (IE8–9) 384

XML 3745, 38081

XMLHttpRequest object

Methods

open(), send() 3723

Properties

responseText 379, 383, 389

responseXML 3802, 389

status 373, 3789, 389

XSS (Cross Site Scripting) Attacks 228231

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.58.194