Workshop 3: Exercise 1: onClick events

Back to Workshop 3 index

Control elements


Exercise 1

Below you will see three buttons. Edit the source code and add an onClick-events to these buttons.

  1. The first button should open an alert-button, which will say "You clicked me!"
  2. When you see the button working, add the current date after the text by using the Date() -function.
  3. The second button should call a function called showTable()". ShowTable function should output a simple HTML-table (below) to the page. Use document.write to print data. Feel free to modify the data on the table.
Name Position Salary
Tiger Nixon System Architect $320,800
Garrett Winters Accountant $170,750
Ashton Cox Junior Technical Author $86,000
Cedric Kelly Senior Javascript Developer $433,060
Airi Satou Accountant $162,700
  1. The last button should check Geolocation of the user, and output it to the console and to the page. Note: Some browsers might not allow you to do this. Try different browsers if you get errors.
Theme