-
-
Save netskink/ce0695b0615d7b44d15c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<head> | |
<meta charset="utf-8"> | |
<title>Click listener version 1</title> | |
</head> | |
<body> | |
<button id="myButton">Click me!</button></button> | |
<script id="jsbin-javascript"> | |
var button = document.getElementById("myButton"); | |
// Add an onclick listener to the button | |
button.onclick = saySomething; | |
function saySomething(event) { | |
console.log("Hello! Button with id: " + | |
event.target.id + | |
" has been clicked"); | |
} | |
</script> | |
<script id="jsbin-source-html" type="text/html"> <head> | |
<meta charset="utf-8"> | |
<title>Click listener version 1</title> | |
</head> | |
<body> | |
<button id="myButton">Click me!</button></button> | |
</body> | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript"> var button = document.getElementById("myButton"); | |
// Add an onclick listener to the button | |
button.onclick = saySomething; | |
function saySomething(event) { | |
console.log("Hello! Button with id: " + | |
event.target.id + | |
" has been clicked"); | |
} | |
</script></body> |
This file contains hidden or 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
var button = document.getElementById("myButton"); | |
// Add an onclick listener to the button | |
button.onclick = saySomething; | |
function saySomething(event) { | |
console.log("Hello! Button with id: " + | |
event.target.id + | |
" has been clicked"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment