Last active
August 29, 2015 14:01
-
-
Save johntron/16aababf50db66b98ea8 to your computer and use it in GitHub Desktop.
The author of the following code intended "You are on the Home page" to appear in a dialog when the button is clicked. It doesn't work this way. Why not?
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>Which page am I on?</button> | |
<script> | |
var Page = { | |
title: 'Home', | |
init: function() { | |
document.querySelector('button').onclick = function () { | |
alert('You are on the ' + this.title + ' page'); | |
}; | |
} | |
}; | |
Page.init(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment