Skip to content

Commit 3c92738

Browse files
committed
Adding Event Listeners
1 parent a0d0af7 commit 3c92738

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

DOM/adding-event-listeners.html

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Adding Event Listeners</title>
8+
</head>
9+
<body>
10+
<div id="output"></div>
11+
<script>
12+
const output = document.getElementById("output");
13+
14+
output.innerHTML = `
15+
<h1 id="title">Adding Event Listeners</h1>
16+
17+
<button type="button" id="btn" class="btn remove buy">Click me</button>
18+
19+
`;
20+
const btn = document.querySelector("button");
21+
22+
function handleClick(event) {
23+
console.log("btn is clicked");
24+
document.getElementById("title").innerText = "Kill Me Heal Me";
25+
26+
console.log(event);
27+
console.log(event.type);
28+
console.log(event.target);
29+
console.log(this);
30+
}
31+
btn.addEventListener("click", handleClick);
32+
</script>
33+
</body>
34+
</html>

DOM/classes.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
const output = document.getElementById("output");
1313

1414
output.innerHTML = `
15-
<h1>Set and Get Inline Styles</h1>
15+
<h1>Set and Get Classes</h1>
1616
<button type="button" class="btn btn-active">Click me</button>
1717
<button type="button" id="btn" class="btn remove buy">Click me</button>
1818

0 commit comments

Comments
 (0)