Skip to main content

Exercise 32

  • Create the following folder/file structure:
/ex_32
|-- index.html

index.html

  • Create a basic HTML document
  • Create a script tag on the document head element
  • Add the following html code
<!DOCTYPE html>
<html>
<head>
<title>Events</title>
</head>
<body>
<div></div>
<button id="firstbutton">Click me!!</button>
</body>
</html>
  • Selec the element with firstbutton id using getElementById
  • When the user clicks the button will see an alert message with the following message:
Oh.. Don't Click Me!!
  • Use the onclick element property
  • Try assigning the function to a variable and then assign the variable to the onclick handler