Created
September 6, 2017 21:58
-
-
Save jimblandy/3196a7b62a8cd052eea90dc18e8284ce to your computer and use it in GitHub Desktop.
Example page illustrating element object properties visible as variables
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
<body> | |
<form id='myform' x="form's attr x"> | |
<input id='mybutton' type='button' y="button's attr y" | |
onclick='console.log("hi, " + x + ", " + y); log_this(); log_that();'> | |
</input> | |
</form> | |
<script> | |
var form = window.document.getElementById('myform'); | |
form.x = "form's property x"; | |
form.log_this = function() { | |
console.log("logging this: ", this); | |
} | |
var button = window.document.getElementById('mybutton'); | |
button.y = "button's property y"; | |
button.log_that = function() { | |
console.log("logging that: ", this); | |
} | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment