Exercise 11.7
This commit is contained in:
parent
1ff3731aed
commit
c3a029061f
43
Chapter 11/Exercise 11.7
Normal file
43
Chapter 11/Exercise 11.7
Normal file
@ -0,0 +1,43 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>JS Tester</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="output1">
|
||||
</div>
|
||||
|
||||
<input type="text" placeholder="First Name" name="first"><br>
|
||||
<input type="text" placeholder="Last Name" name="last"><br>
|
||||
<script>
|
||||
const output = document.querySelector(".output1");
|
||||
|
||||
const in1 = document.querySelector("input[name='first']");
|
||||
const in2 = document.querySelector("input[name='last']");
|
||||
in1.addEventListener("change", (e) => {
|
||||
console.log("change");
|
||||
updater(in1.value);
|
||||
})
|
||||
in1.addEventListener("blur", (e) => {
|
||||
console.log("blur");
|
||||
})
|
||||
in1.addEventListener("focus", (e) => {
|
||||
console.log("focus");
|
||||
})
|
||||
in2.addEventListener("change", (e) => {
|
||||
console.log("change");
|
||||
updater(in2.value);
|
||||
})
|
||||
in2.addEventListener("blur", (e) => {
|
||||
console.log("blur");
|
||||
})
|
||||
in2.addEventListener("focus", (e) => {
|
||||
console.log("focus");
|
||||
})
|
||||
function updater(str) {
|
||||
output.textContent = str;
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user