Chapter 4. The Interactivity
So far, we’ve studied three very important aspects of web application development. Sadly, however, we haven’t built an application that actually does anything. We’ve just been able to structure content and then style it so it looks interesting.
In this chapter, we’re going to start exploring interactivity. This will allow us to go beyond building web pages that don’t change. Instead, we’ll begin building dynamic applications that respond to user input.
To this end, we’ll learn a little bit about JavaScript, the scripting language that runs inside every web browser, and jQuery, a JavaScript library that’s useful for manipulating the DOM (among other things). In addition, we’ll spend some time learning the basics of JavaScript as a language, with an emphasis on using and manipulating arrays.
Hello, JavaScript!
Let’s start with an example. As before, we’ll create a directory in Projects called Chapter4. In this directory, we’ll start by creating a subdirectory called Example1 and open that directory in Sublime. Next, we’ll create three files: index.html, style.css, and app.js. We’ll start with index.html:
<!doctype html><html><head><title>App Name</title><linkhref="style.css"rel="stylesheet"type="text/css"></head><body><h1>App Name</h1><p>App Description</p><scriptsrc="http://code.jquery.com/jquery-2.0.3.min.js"></script><scriptsrc="app.js"></script></body></html>
Everything in index.html should be familiar with the exception of the <script> ...
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.
Read now
Unlock full access