Exercise 11.8

This commit is contained in:
Karan 2021-11-24 22:21:02 +05:30 committed by GitHub
parent c3a029061f
commit 3059c11f1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

28
Chapter 11/Exercise 11.8 Normal file
View File

@ -0,0 +1,28 @@
<!doctype html>
<html>
<head>
<title>JS Tester</title>
</head>
<body>
<div class="output"></div>
<input type="text" name="myNum1">
<input type="text" name="myNum2">
<script>
const eles = document.querySelectorAll("input");
const output = document.querySelector(".output");
eles.forEach(el => {
el.addEventListener("keydown", (e) => {
if (!isNaN(e.key)) {
output.textContent += e.key;
}
})
el.addEventListener("keyup", (e) => {
console.log(e.key);
})
el.addEventListener("paste", (e) => {
console.log('pasted');
})
})
</script>
</body>
</html>