Created
March 12, 2017 10:11
-
-
Save Dosant/1f34b266fa076e44574f0d6a5ebf3c7c 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
<input id="my-input" type="text" value="Text"> | |
<button id="clear-button">Clear</button> | |
<p id="my-p">Text</p> |
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
var input = document.getElementById('my-input'); | |
var clearButton = document.getElementById('clear-button'); | |
var p = document.getElementById('my-p'); | |
function handleUserInput() { | |
p.textContent = input.value; | |
} | |
function handleClearClick() { | |
p.textContent = ''; | |
input.value = ''; | |
} | |
input.addEventListener('input', handleUserInput); | |
clearButton.addEventListener('click', handleClearClick); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment