-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
107 lines (91 loc) · 2.6 KB
/
script.js
File metadata and controls
107 lines (91 loc) · 2.6 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Task 1
let newTab = window.open("", "window", "width = 300, height = 300 ");
setTimeout(function() {
newTab.resizeTo(500, 500);
}, 2000);
setTimeout(function() {
newTab.moveTo(200, 200);
}, 3000);
setTimeout(function() {
newTab.close();
}, 4000);
//Task 2
function changeCss() {
let paragraf = document.getElementById("text");
paragraf.style.color = "orange";
paragraf.style.fontSize = "20px";
paragraf.style.fontFamily = "Comic Sans MS";
}
let btn = document.getElementById("btn");
btn.addEventListener("click", changeCss);
// Task 3
let body = document.getElementById("body");
function backgroundColor() {
body.style.backgroundColor = "blue";
}
function backgroundColorP() {
body.style.backgroundColor = "pink";
}
function mouseDown() {
document.getElementById("body").style.backgroundColor = "brown";
}
function mouseOver() {
document.getElementById("body").style.backgroundColor = "yellow";
}
function mouseOut() {
document.getElementById("body").style.backgroundColor = "white";
}
let btn2 = document.getElementById("btn2");
let btn3 = document.getElementById("btn3");
btn1.addEventListener("click", backgroundColor);
btn2.addEventListener("dblclick", backgroundColorP);
btn3.addEventListener("mousedown", mouseDown);
btn3.addEventListener("mouseout", mouseOut);
linck.addEventListener("mouseover", mouseOver);
linck.addEventListener("mouseout", mouseOut);
// Task 4
function deleteElement() {
let x = document.getElementById("list");
x.remove(x.selectedIndex);
}
sub.addEventListener("click", deleteElement);
// Task 5
function liveButton() {
//let p = document.createElement("p");
// p.innerHTML = "Mouse on me!"; // 1
//live.after(p);
live.insertAdjacentHTML("afterend", "<p>Mouse on me!<p>"); //2
}
live.addEventListener("mouseover", liveButton);
function presBotton() {
live.insertAdjacentHTML("afterend", "<p>I wos presed!<p>");
}
live.addEventListener("click", presBotton);
function outBotton() {
live.insertAdjacentHTML("afterend", "<p>Mous is not on me!<p>");
}
live.addEventListener("mouseout", outBotton);
function del(event) {
let x = event.target;
if (x.tagName == "P") {
x.remove();
}
}
document.addEventListener("click", del);
// Task 6
function widthHeight() {
window.innerHTML = document.write(
"Width: " + window.innerWidth,
", ",
" Height: " + window.innerHeight
);
}
widthHeight();
document.addEventListener("change", widthHeight);
// Task 7
let country = {
USA: ["New - York", "Boston", "Chicago", "Washington"],
Ukraine: ["Lviv", "Kyiv", "Odessa", "Dnipro"],
England: ["London", "Liverpol", "Totenhem", "Cambridge"]
};
console.log(country[0]);