Skip to Content
JavaScript for Kids
book

JavaScript for Kids

by Nick Morgan
December 2014
Beginner content levelBeginner
336 pages
6h 32m
English
No Starch Press
Content preview from JavaScript for Kids

Chapter 10. Interactive Programming

Until now, the JavaScript code on our web pages has run as soon as the page is loaded, pausing only if we include a call to a function like alert or confirm. But we don’t always necessarily want all of our code to run as soon as the page loads—what if we want some code to run after a delay or in response to something the user does?

In this chapter, we’ll look at different ways of modifying when our code is run. Programming in this way is called interactive programming. This will let us create interactive web pages that change over time and respond to actions by the user.

Delaying Code with setTimeout

Instead of having JavaScript execute a function immediately, you can tell it to execute a function after a certain ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

JavaScript For Kids For Dummies

JavaScript For Kids For Dummies

Chris Minnick, Eva Holland
JavaScript Projects for Kids

JavaScript Projects for Kids

Syed Omar Faruk Towaha

Publisher Resources

ISBN: 9781457189838Errata Page