Skip to content

Instantly share code, notes, and snippets.

@harrisonmalone
Last active November 19, 2018 10:46
Show Gist options
  • Save harrisonmalone/566d8a252c971e7157aadba94b617570 to your computer and use it in GitHub Desktop.
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
<!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>
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