Home > Store

JavaScript in 24 Hours, Sams Teach Yourself, 5th Edition

Register your product to gain access to bonus material or receive a coupon.

JavaScript in 24 Hours, Sams Teach Yourself, 5th Edition

Book

  • Sorry, this book is no longer in print.
Not for Sale

Description

  • Copyright 2013
  • Edition: 5th
  • Book
  • ISBN-10: 0-672-33608-1
  • ISBN-13: 978-0-672-33608-9

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 codecademy.com/tracks/teachyourself



Downloads

Downloads

Download free code files for Sams Teach Yourself JavaScript in 24 Hours here

Sample Content

Online Sample Chapter

Using Functions in JavaScript

Sample Pages

Download the sample pages (includes Chapter 3 and Index)

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

Workshop      

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

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020