1. Create four buttons in HTML with each button labeled with a number like
this. Using the onclick event,
make all the buttons respond to a click by calling a single function you define like
this. Study the code.
Now modify the code so that it tells the user which button has been clicked. (Hint:
each button when calling the function should use arguments to identify which button it is).
If you click button #2, the alert message should say "button #2 was clicked". If button #4 is clicked,
the alert message should say "button #4 was clicked".
2. Study
eventhandler03.html and/or
eventhandler04.html.
You are going to learn something new on your own.
innerHTML object represents the HTML content of the DOM object (HTML element) you are working with.
So if you are working with a <p> tag, any HTML inside the <p> tag is represented by the
innerHTML object. You can read or write to innerHTML thereby
dynamically modifying the HTML on the fly.
"this" in javascript represents the DOM object you are currently on. (This is a tricky concept!!). So if you write
this.innerHTML, it represents
the HTML content of the HTML tag/object javascript is working on.
Using
eventhandler03.html and/or
eventhandler04.html as a starting point, make a page
full of text (many paragraphs) that changes as the user moves their mouse along.
It is important you understand the difference between document.write() and this.innerHTML