Skip to content

Instantly share code, notes, and snippets.

Last active November 25, 2015 10:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
<button id="myButton"> Hello World! </button>
var button = document.getElementById("myButton")
function speak(){ alert("hi!") } // this is a function declaration, allowing 'speak' to be used anywhere in the code, even above this line.
//you can also assign an "anonymous function" to a variable name, but this function can only be called below where it was assigned
//var speak = function() { alert("hi!") }
button.onclick = speak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment