-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfour.html
More file actions
44 lines (40 loc) · 1.08 KB
/
four.html
File metadata and controls
44 lines (40 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>addEventListener</title>
<style>
body{
background: #000000e7;
}
.container{
display: flex;
gap:0.5rem;
flex-direction: column;
}
button{
width: 200px;
border: none;
}
</style>
</head>
<body>
<div class="container">
<textarea class="story"></textarea>
<button id="set-text" type="button">Set text content</button>
<button id="clear-text" type="button">Clear text content</button>
</div>
</body>
<script>
const story = document.body.querySelector(".story");
const setText = document.body.querySelector("#set-text");
setText.addEventListener("click", ()=>{
story.textContent ="Welcome bhai...";
});
const clearText = document.body.querySelector("#clear-text");
clearText.addEventListener("click", ()=>{
story.textContent ="";
});
</script>
</html>