HTML and CSS Reference
In-Depth Information
chapter ten
Introducing JavaScript
UP TO THIS point in the book, you focused on how to create web pages using HTML. In the remaining chapters,
you are going to be using JavaScript and HTML5 to create interactive features for your Joe's Pizza Co. website. But
first, you need to get up to speed about the JavaScript programming language.
The JavaScript programming language is a very large topic, possibly even bigger than HTML and CSS combined. In
this chapter I introduce you to the basic concepts of JavaScript so that you can build a foundation on which to enhance
your JavaScript knowledge in the future. You will step away from the Joe's Pizza Co. website for a while, and focus
instead on building a number of small JavaScript programs. As you progress through each of these exercises you will
learn about the key concepts of programming. In the following chapters, you'll return to the Joe's Pizza Co. website
and put your new knowledge to use.
You'll start by learning how to add JavaScript to your web pages, by either putting the code inline with your existing
HTML or in separate JavaScript files. You will learn how to write your own programs in JavaScript, how JavaScript
programs are constructed, and the various tools available to you as a developer. These include control and loop struc-
tures as well as how to select and manipulate elements within your pages.
You'll also look at the Document Object Model (DOM), what it is, how it is created, and why it is important. You will
also learn about DOM nodes and the relationships between them.
Finally, you will look at a JavaScript library called jQuery and how it can be used to make writing JavaScript pro-
grams easier.
Treehouse offers a great JavaScript Foundations course that I recommend you work through in conjunction with this
chapter. You can find it at http://teamtreehouse.com/library/websites/javascript-foundations .
What is JavaScript?
JavaScript is a general purpose programming language that is used to create dynamic and interactive websites.
Brendan Eich originally designed the language while working on the Netscape browser in 1995; he's now the Chief
Technology Officer at Mozilla (the non-profit organization that develops, among other things, the Firefox web
browser).
So what are dynamic websites ? JavaScript enables developers to write programs that can change how a website looks
and behaves once it has loaded into the user's browser. This means that you could update some of the content in the
page without having to reload the page. You can even request new content from a web server and display it on the
page without having to refresh it. This is referred to as Asynchronous JavaScript and XML , or AJAX . Many popular
web applications such as Gmail and Facebook make heavy use of AJAX to create fast interfaces.
Search WWH ::




Custom Search