Skip to content

Instantly share code, notes, and snippets.

@johntron
Last active January 2, 2016 09:39
Show Gist options
  • Save johntron/8284931 to your computer and use it in GitHub Desktop.
Save johntron/8284931 to your computer and use it in GitHub Desktop.
This code should update the <div> with the value the user entered when "update" is clicked, but it does not. Why, and how do you fix this? Assume you cannot change the show() function.
<div class="number"></div>
<input type="text" /><button class="update">update</button>
<script type="text/javascript">
var $number = document.querySelector('.number');
var $input = document.querySelector('input');
function show() {
$number.innerHTML = this.value;
}
document.querySelector('button').onclick = show;
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment