-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDOM_events.html
More file actions
57 lines (51 loc) · 1.75 KB
/
Copy pathDOM_events.html
File metadata and controls
57 lines (51 loc) · 1.75 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
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DOM Special Event</title>
</head>
<body>
<h1 onclick="console.log('I am 1')">Dom ar ajke special event</h1>
<button onclick="console.log('I am 2')">Click Me</button>
<button onclick="console.log('I am 3')">Click Me</button>
<button onclick="document.body.style.backgroundColor='yellow'" >Make Yellow</button>
<button onclick="makeRed()">Make Red</button>
<button id="make-blue">Make Blue</button>
<button id="make-pink">Make Pink</button>
<button id="make-green">Make Green</button>
<button id="make-purple">Make Purple</button>
<script src="script/DOM_events.js"></script>
<script>
// option 1
const makeblue=document.getElementById('make-blue');
makeblue.onclick=makeBlue;
function makeBlue()
{
document.body.style.backgroundColor='blue';
}
// option 2
function makeRed()
{
document.body.style.backgroundColor='red';
}
//option 3
const makepink=document.getElementById('make-pink');
makepink.addEventListener('click',makePink);
function makePink()
{
document.body.style.backgroundColor='pink';
}
//option 4
const makegreen=document.getElementById('make-green');
makegreen.addEventListener('click',function makeGreen()
{
document.body.style.backgroundColor='green';
});
//option 5
document.getElementById('make-purple').addEventListener('click',function(){
document.body.style.backgroundColor='purple';
});
</script>
</body>
</html>