Sams Teach Yourself JavaScript in 24 Hours [NOOK Book]


Learn JavaScript in 24 Hours

Covers JavaScript 1.8+, Ajax and jQuery

In just 24 lessons of one hour or less, you can learn how to create dynamic, interactive Web pages with the popular and ubiquitous JavaScript web programming ...

See more details below
Sams Teach Yourself JavaScript in 24 Hours

Available on NOOK devices and apps  
  • NOOK Devices
  • Samsung Galaxy Tab 4 NOOK 7.0
  • Samsung Galaxy Tab 4 NOOK 10.1
  • NOOK HD Tablet
  • NOOK HD+ Tablet
  • NOOK eReaders
  • NOOK Color
  • NOOK Tablet
  • Tablet/Phone
  • NOOK for Windows 8 Tablet
  • NOOK for iOS
  • NOOK for Android
  • NOOK Kids for iPad
  • PC/Mac
  • NOOK for Windows 8
  • NOOK for PC
  • NOOK for Mac

Want a NOOK? Explore Now

NOOK Book (eBook)
$15.49 price
(Save 44%)$27.99 List Price


Learn JavaScript in 24 Hours

Covers JavaScript 1.8+, Ajax and jQuery

In just 24 lessons of one hour or less, you can learn how to create dynamic, interactive Web pages with the popular and ubiquitous JavaScript web programming language.

Using a straightforward, step-by-step approach, each lesson in this book clearly and carefully walks you through basic concepts and techniques, and helps you learn the essentials of JavaScript programming from the ground up.

Learn how to…

  • Use JavaScript to build dynamic, interactive Web pages
  • Debug scripts
  • Create scripts that work in all browsers
  • Work with HTML5 and CSS3
  • Leverage the popular jQuery library
  • Control CSS with simple JavaScripts
  • Add Ajax effects to your web pages
  • Script animations and music

Step-by-step instructions carefully walk you through the most common JavaScript programming tasks

Quizzes at end of every chapter help you build and test your knowledge

Interactive online exercises let you practice what you learn at the Codecademy web site with no downloads or installation needed

Sams Publishing has teamed up with Codecademy — the online place where anyone can learn and teach coding — to provide readers of Sams Teach Yoruself JavaScript in 24 Hours with an exclusive area on the Codecademy web site where you can supplement what you've learned in this book with some fun, fully interactive exercises and projects. After reading a lesson in the book you can roll up your sleeves and get some hands-on coding experience at

Read More Show Less

Product Details

  • ISBN-13: 9780133048315
  • Publisher: Pearson Education
  • Publication date: 11/19/2012
  • Series: Sams Teach Yourself
  • Sold by: Barnes & Noble
  • Format: eBook
  • Edition number: 5
  • Pages: 448
  • Sales rank: 751,740
  • File size: 25 MB
  • Note: This product may take a few minutes to download.

Meet the Author

Phil Ballard is a professional web consultant specializing in website and intranet design, search engine optimization, server-side scripting, client-side design, and programming and hosting. He has written a number of books and online tutorials, including Sams Teach Yourself Ajax in 10 Minutes.

Michael Moncur is the owner of Starling Technologies, a consulting firm specializing in networking and the Internet. He is also a freelance webmaster and author, and has written books on JavaScript, networking, and MCSE training.

Read More Show Less

Table of Contents

Introduction 1

Who This Book Is For 1

The Aims of This Book 1

Conventions Used 2

Q&A, Quiz, and Exercises 2

How the Book Is Organized 2

Tools You’ll Need 3

PART I: First Steps with JavaScript 5

HOUR 1: Introducing JavaScript 7

Web Scripting Fundamentals 7

Server- Versus Client-Side Programming 8

JavaScript in a Nutshell 8

Where JavaScript Came From 9

The <script> Tag 10

Introducing the DOM 11

Talking to the User 13

Summary 17

Q&A 18

Workshop 18

Exercises 19

HOUR 2: Writing Simple Scripts 21

Including JavaScript in Your Web Page 21

JavaScript Statements 23

Variables 24

Operators 26

Capturing Mouse Events 30

Summary 33

Q&A 34

Workshop 34

Exercises 35

HOUR 3: Using Functions 37

General Syntax 37

Calling Functions 38

Arguments 40

Returning Values from Functions 43

Scope of Variables 44

Summary 46

Q&A 47

Workshop 47

Exercises 48

HOUR 4: DOM Objects and Built-In Objects 49

Interacting with the User 49

Selecting Elements by Their id 51

Accessing Browser History 52

Using the location Object 53

Browser Information—The navigator Object 54

Dates and Times 57

Simplifying Calculation with the Math Object 59

Summary 64

Q&A 65

Workshop 65

Exercises 66

HOUR 5: Different Types of Data 67

Numbers 67

Strings 70

Boolean Values 73

Arrays 74

Summary 79

Q&A 80

Workshop 80

Exercises 81

PART II: More Advanced JavaScript 83

HOUR 6: Scripts That Do More 85

Conditional Statements 85

Loops and Control Structures 90

Debugging Your Scripts 94

Summary 100

Q&A 101

Workshop 101

Exercises 102

HOUR 7: Object Oriented Programming 103

What Is Object Oriented Programming (OOP)? 103

Object Creation 104

Extending and Inheriting Objects Using prototype 111

Encapsulation 115

Using Feature Detection 116

Summary 118

Q&A 119

Workshop 119

Exercises 120

HOUR 8: Meet JSON 121

What Is JSON? 121

Accessing JSON Data 123

Data Serialization with JSON 124

JSON Data Types 126

Simulating Associative Arrays 127

Creating Objects with JSON 127

JSON Security 131

Summary 132

Q&A 133

Workshop 133

Exercises 134

HOUR 9: Responding to Events 135

Understanding Event Handlers 135

Default Actions 138

The event Object 141

Cross-Browser Event Handlers 142

Advanced Event Handler Registration 146

Summary 151

Q&A 152

Workshop 152

Exercises 153

HOUR 10: JavaScript and Cookies 155

What Are Cookies? 155

The document.cookie Property 156

Cookie Ingredients 157

Writing a Cookie 158

A Function to Write a Cookie 159

Reading a Cookie 161

Deleting Cookies 162

Setting Multiple Values in a Single Cookie 165

Summary 166

Q&A 166


Exercises 168

PART III: Working with the Document Object Model (DOM) 169

HOUR 11: Navigating the DOM 171

DOM Nodes 171

Selecting Elements with getElementsByTagName() 177

Reading an Element’s Attributes 179

Mozilla’s DOM Inspector 180

Summary 181

Q&A 182

Workshop 182

Exercises 183

HOUR 12: Scripting the DOM 185

Creating New Nodes 185

Manipulating Child Nodes 187

Editing Element Attributes 191

Dynamically Loading JavaScript Files 192

Summary 198

Q&A 199

Workshop 199

Exercises 200

HOUR 13: JavaScript and CSS 201

A Ten Minute CSS Primer 201

The DOM style Property 204

Accessing Classes Using className 207

The DOM styleSheets Object 209

Summary 214

Q&A 215

Workshop 215

Exercises 216

HOUR 14: Good Coding Practice 217

Don’t Overuse JavaScript 217

Writing Readable and Maintainable Code 218

Graceful Degradation 221

Progressive Enhancement 222

Unobtrusive JavaScript 223

Feature Detection 226

Handling Errors Well 227

Summary 231

Q&A 232

Workshop 232

Exercises 233

HOUR 15: Graphics and Animation 235

Preloading Images 235

Animating Page Elements 236

Animating Transparency 238

CSS3 Transitions, Transformations, and Animations 239

Scripting DOM Positioning 240

Optimizing Performance 242

Summary 245

Q&A 246

Workshop 246

Exercises 247

PART IV: Ajax 249

HOUR 16: Introducing Ajax 251

The Anatomy of Ajax 251

The XMLHttpRequest Object 256

Creating Instances of XMLHttpRequest 256

Sending the Server Request 260

Monitoring Server Status 263

Callback Functions 264

responseText and responseXML Properties 265

Summary 269

Q&A 270

Workshop 270

Exercises 271

HOUR 17: Creating a Simple Ajax Library 273

An Ajax Library 273

Implementing the Library 274

Using the Library 278

Summary 284

Q&A 285

Workshop 285

Exercises 286

HOUR 18: Solving Ajax Problems 287

Debugging Ajax Applications 287

Common Ajax Errors 292

Some Programming Gotchas 297

Summary 298

Q&A 299

Workshop 299

Exercises 300

PART V: Using JavaScript Libraries 301

HOUR 19: Making Life Easier with Libraries 303

Why Use a Library? 303

What Sorts of Things Can Libraries Do? 304

Some Popular Libraries 305

Introducing prototype.js 306

Summary 313

Q&A 314

Workshop 314

Exercises 315

HOUR 20: A Closer Look at jQuery 317

Including jQuery in Your Pages 317

jQuery’s $(document).ready Handler 318

Selecting Page Elements 319

Working with HTML Content 320

Showing and Hiding Elements 321

Animating Elements 322

Command Chaining 324

Handling Events 328

Using jQuery to Implement Ajax 328

Summary 332

Q&A 333

Workshop 333

Exercises 334

HOUR 21: The jQuery UI User Interface Library 335

What jQuery UI Is All About 335

How to Include jQuery UI in Your Pages 336

Interactions 337

Using Widgets 343

Summary 348

Q&A 349

Workshop 349

Exercises 350

PART VI: Using JavaScript with Other Web Technologies 351

HOUR 22: JavaScript and Multimedia 353

Multimedia Formats 353

Browser Plug-Ins 355

Using an Anchor Tag 356

Using <embed> and <object> 356

Flash 358

Summary 362

Q&A 363

Workshop 363

Exercises 364

HOUR 23: HTML5 and JavaScript 365

New Markup for HTML5 365

Some Important New Elements 366

Drag and Drop 373

Local Storage 376

Working with Local Files 377

Summary 379

Q&A 380

Workshop 380

Exercises 381

HOUR 24: JavaScript Beyond the Web Page 383

JavaScript Outside the Browser 383

Writing Google Chrome Extensions 384

Summary 394

Q&A 395

Workshop 395

Exercises 396

PART VII: Appendices 397

APPENDIX A: Tools for JavaScript Development 399

Editors 399

Validators 400

Debugging and Verifying Tools 401

APPENDIX B: JavaScript Quick Reference 403

Index 411

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Terms of Use.
  • - Barnes & reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)