Last active
November 19, 2018 10:46
-
-
Save harrisonmalone/566d8a252c971e7157aadba94b617570 to your computer and use it in GitHub Desktop.
another example of using a input event listener to append text to the body of html, was also using this to test debugger
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 lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
<link rel="stylesheet" href="style.css"> | |
<script defer src="script.js"></script> | |
</head> | |
<body> | |
<form> | |
<label for="">Username</label> | |
<input type="text"> | |
</form> | |
</body> | |
</html> |
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
const username = document.querySelector("input") | |
const para = document.createElement("p") | |
username.addEventListener("input", function(e) { | |
const input = e.target.value | |
para.innerText = input | |
document.body.appendChild(para) | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment