-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
58 lines (46 loc) · 1.43 KB
/
index.js
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
58
window.addEventListener("click", function (event) {
console.log("== The window was clicked")
console.log(" -- event.target:", event.target)
console.log(" -- event.currentTarget:", event.currentTarget)
})
function boxClickHandler(event) {
console.log("== A box was clicked")
console.log(" -- event.target:", event.target)
console.log(" -- event.currentTarget:", event.currentTarget)
}
var boxes = document.getElementsByClassName("box")
for (var i = 0; i < boxes.length; i++) {
boxes[i].addEventListener("click", boxClickHandler)
}
function buttonClickHandler(event) {
console.log("== A button was clicked")
console.log(" -- event:", event)
console.log(" -- event.target:", event.target)
console.log(" -- event.currentTarget:", event.currentTarget)
var box = event.currentTarget.parentNode
box.classList.toggle("highlighted")
event.stopPropagation()
}
var buttons = document.getElementsByClassName("in-box-button")
for (var i = 0; i < buttons.length; i++) {
buttons[i].addEventListener("click", buttonClickHandler)
}
var link = document.getElementById("website-link")
link.addEventListener("click", function (event) {
console.log("== The link was clicked")
event.preventDefault()
})
function one() {
return 1
}
function two() {
return 2
}
function three() {
return 3
}
function addThree(a, b, c) {
return a + b + c
}
addThree(one(), two(), three())
addThree(1, 2, 3)