Last active
November 25, 2015 10:01
-
-
Save jazzyjackson/485a3e771b6488f85f77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<button id="myButton"> Hello World! </button> | |
<script> | |
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 | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment