Created
November 9, 2014 01:20
-
-
Save snippe/9f9200619502dfce525b to your computer and use it in GitHub Desktop.
Specifying object
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='thebutton'>Click me!</button> |
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
function Person(name) { | |
this.name = name; | |
this.sayHello = function () { | |
alert('Hello ' + this.name); | |
} | |
} | |
function addhandler() { | |
var p1 = new Person('Jason'), | |
the_button = document.getElementById('thebutton'); | |
the_button.onclick = p1.sayHello.call(p1); | |
} | |
window.onload = addhandler; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment