Project 1

This commit is contained in:
Karan 2021-11-24 22:51:08 +05:30 committed by GitHub
parent 628ea4d60a
commit e54eaabf63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

33
Chapter 11/Project 1 Normal file
View File

@ -0,0 +1,33 @@
<!doctype html >
<html>
<head>
<title>JS Tester</title>
<style>.box{width:200px;height:100px;border:1px solid black}</style>
</head>
<body>
<div class="container">
<div class="box" id="box0">Box #1</div>
<div class="box" id="box1">Box #2</div>
<div class="box" id="box2">Box #3</div>
<div class="box" id="box3">Box #4</div>
</div>
<script>
const counter = [];
const main = document.querySelector(".container");
main.addEventListener("click",tracker);
function tracker(e){
const el = e.target;
if(el.id){
const temp = {};
temp.content = el.textContent;
temp.id = el.id;
temp.tagName = el.tagName;
temp.class = el.className;
console.dir(el);
counter.push(temp);
console.log(counter);
}
}
</script>
</body>
</html>