HTML and CSS Reference
The benefit of attaching functions to objects is that the function will be able to access all of the object's prop-
erties, whereas if the function were not attached to an object the desired properties would have to be passed
to the function through parameters.
• event —An event is triggered when certain conditions are met. For example, the onload event is triggered
when the page loads. There are also events for things like mouse clicks, key presses, and form submissions.
You can use event listeners to attach functions to events so that a function is executed when an event is
Awesome, aren't they! If you aren't brimming with excitement at what is possible now, don't worry. You soon will
amazing as those demos.
The <script> Element
file), or you can put it in a completely separate file and link to that file in your HTML. The latter method is generally
However, there are times when inline scripts are needed, so in this section I cover both methods. Whichever method
you end up using in your projects, you are going to use the <script> element to let the browser know where your
you put it in its own dedicated file.
The example code used in this chapter is available from the Chapter 10 folder in the download code files.
2. Now create a new file in your text editor.
4. Copy the following code into the example10-1.html file.