HTML and CSS Reference
In-Depth Information
EXAMPLE 7.4 ( CONTINUED )
3
<body>
<div align="center">
4
<form>
5
<input type="button"
6
value="Welcome button"
7
onClick="greetings('Dan');"
/>
</form>
</div>
</body>
</html>
EXPLANATION
1
The JavaScript program starts here. The function is defined in the head of the doc-
ument.
2
The function greetings() is defined here.
3
The body of the page starts here.
4
An HTML form starts here. It will be used to create a button input device.
5
The type of input device is a button.
6
The value that will be displayed in the button is “Welcome button” (see Figure 7.6).
7
When the user presses or clicks the button, the onClick event handler will be trig-
gered, causing the greetings() function to be called. The value assigned to the on-
Click event handler is a JavaScript function enclosed in quotation marks (see Fig-
ure 7.7).
Figure 7.6 When the button is clicked, the event is triggered.
Search WWH ::




Custom Search