Created
November 10, 2013 15:43
-
-
Save mdarby/7399729 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script type="text/javascript"> | |
/* | |
The "this" parameter is just relabled as "button" here for our own clarity | |
Note: You cannot use the "this" keyword as a parameter argument name. | |
*/ | |
function modifyButtonLabel(button) { | |
/* No need to look up / get a handle on the input as 'button' already contains it */ | |
button.setAttribute("value", "New label"); | |
} | |
</script> | |
</head> | |
<body> | |
<!-- | |
The "this shorthand syntax" is simply adding the "this" keyword as a parameter | |
"this" is a keyword that literally contains a context of what "this" is -- whatever object you're dealing with. | |
--> | |
<input type="button" value="Modify my label!" onClick="modifyButtonLabel(this)"></input> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment