Skip to content

Instantly share code, notes, and snippets.

@jimblandy
Created September 6, 2017 21:58
Show Gist options
  • Save jimblandy/3196a7b62a8cd052eea90dc18e8284ce to your computer and use it in GitHub Desktop.
Save jimblandy/3196a7b62a8cd052eea90dc18e8284ce to your computer and use it in GitHub Desktop.
Example page illustrating element object properties visible as variables
<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