Lesson Nine: The Button Object
- Enter this code into your HTML file (histevents.html) under the h1 element to create a button:
<input type="button" id="b1" value="Click the Button to see Event One" onclick="historyevents(1);">
- The input tag identifies the input element.
- The input element can contain various objects that are identified by the type attribute. In this case the type is a button object.
- The id attribute identifies the button object. In this case the button has the id of b1.
- The value attribute contains the text that is to be shown in the button element.
button = document.getElementById("b1"); button.value = event1; }
The above code is explained in the next lesson.
- Test your program with the new code. Your page should look like this: Sample