Created
August 15, 2017 19:57
-
-
Save romulomourao/969fedaa9e9ec18ddfe60cee4f34acf9 to your computer and use it in GitHub Desktop.
JS STI // source https://jsbin.com/yayesan/1
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS STI</title> | |
<style id="jsbin-css"> | |
body{ | |
display: flex; | |
height: 100vh; | |
align-items: center; | |
justify-content: center; | |
background-color: #e7e7e7; | |
} | |
a{ | |
background-color: #35BBFE; | |
color: white; | |
padding: 10px 30px; | |
display: block; | |
} | |
</style> | |
</head> | |
<body> | |
<a id="my-button">Click</a> | |
<script id="jsbin-javascript"> | |
//this and bind | |
let dog = { | |
sound :'woof', | |
talk: function() { | |
console.log(this.sound); | |
} | |
} | |
let button = document.getElementById('my-button'); | |
button.addEventListener('click', dog.talk); | |
//button.addEventListener('click', dog.talk.bind(dog)); | |
</script> | |
<script id="jsbin-source-css" type="text/css">body{ | |
display: flex; | |
height: 100vh; | |
align-items: center; | |
justify-content: center; | |
background-color: #e7e7e7; | |
} | |
a{ | |
background-color: #35BBFE; | |
color: white; | |
padding: 10px 30px; | |
display: block; | |
}</script> | |
<script id="jsbin-source-javascript" type="text/javascript">//this and bind | |
let dog = { | |
sound :'woof', | |
talk: function() { | |
console.log(this.sound); | |
} | |
} | |
let button = document.getElementById('my-button'); | |
button.addEventListener('click', dog.talk); | |
//button.addEventListener('click', dog.talk.bind(dog)); | |
</script></body> | |
</html> |
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
body{ | |
display: flex; | |
height: 100vh; | |
align-items: center; | |
justify-content: center; | |
background-color: #e7e7e7; | |
} | |
a{ | |
background-color: #35BBFE; | |
color: white; | |
padding: 10px 30px; | |
display: block; | |
} |
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
//this and bind | |
let dog = { | |
sound :'woof', | |
talk: function() { | |
console.log(this.sound); | |
} | |
} | |
let button = document.getElementById('my-button'); | |
button.addEventListener('click', dog.talk); | |
//button.addEventListener('click', dog.talk.bind(dog)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment