Exercise 11.4

This commit is contained in:
Karan 2021-11-24 22:19:36 +05:30 committed by GitHub
parent 36059d206e
commit 2e53589a41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

32
Chapter 11/Exercise 11.4 Normal file
View File

@ -0,0 +1,32 @@
<!doctype html>
<html>
<head>
<title>JS Tester</title>
</head>
<body>
<div class="output"></div>
<script>
const output = document.querySelector(".output");
output.textContent = "hello world";
output.style.height = "200px";
output.style.width = "400px";
output.style.backgroundColor = "red";
output.addEventListener("mousedown", function (e) {
message("green", e);
})
output.addEventListener("mouseover", function (e) {
message("red", e);
})
output.addEventListener("mouseout", function (e) {
message("yellow", e);
})
output.addEventListener("mouseup", function (e) {
message("blue", e);
})
function message(elColor, event) {
console.log(event.type);
output.style.backgroundColor = elColor;
}
</script>
</body>
</html>