Skip to content

Instantly share code, notes, and snippets.

@mdarby
Created November 10, 2013 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdarby/7399729 to your computer and use it in GitHub Desktop.
Save mdarby/7399729 to your computer and use it in GitHub Desktop.
<!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