-
Notifications
You must be signed in to change notification settings - Fork 1
/
proba 4 urok.html
209 lines (139 loc) · 3.95 KB
/
proba 4 urok.html
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JS.4</title>
</head>
<body>
<a> text v body </a>
<h1 id = "zagol">UR4. Zagolovok h1</h1>
<span>napisal so span stilizovat`</span> <!-- стилизовать после с css -->
<script>
// console.log('document: ', document);
// console.dir(document);
console.log(document.body.children);
// console.log(document.body.childNodes);
// let h1 = document.body.children[0];
let h1Zagol = document.getElementById('zagol');
console.log('h1Zagol', h1Zagol);
h1Zagol.style.color = 'red';
</script>
<ul class = "list"> </ul>
<li class= "list-item">hleb</li>
<li class= "list-item">mmilk</li>
<li class= "list-item">tea</li>
<li class= "list-item">water</li>
<script>
let listItems = document.getElementsByClassName('list-item');
console.log("list-items", listItems);
// listItems.style.color = 'red'; /* не работает тк массив */
for (let item of listItems) {
item.style.color = 'blue'; /* item - eto li */
};
</script>
<p> </p>
<button class = btn>BTNBTNBTN1</button>
<button class = btn>BTNBTNBTN2</button>
<button class = btn>BTNBTNBTN3</button>
<button class = btn>BTNBTNBTN4</button>
<script>
let firstBtn = document.querySelector('.btn');
console.log(firstBtn.tagName);
firstBtn.style.color = 'blue';
firstBtn.style.backgroundColor = 'yellow';
let allBtn = document.querySelectorAll('.btn');
console.log('allBtn', allBtn);
for (let btn of allBtn) {
btn.style.color = 'green';
btn.style.backgroundColor = 'yellow';
};
</script>
<p> </p>
<a id = 'yaLink' href="https://ya.ru">yandex</a>
<p></p>
<img id = 'image' src="https://avatars.mds.yandex.net/i?id=2528a554934f4864aed3f70ff6690c4f21c6c16e-5864121-images-thumbs&n=13" alt="" height = '150'>
<p></p>
<script>
let yaLink = document.getElementById('yaLink');
yaLink.id = 'googleLink';
yaLink.href = 'https://google.com';
let img = document.querySelector('image');
</script>
<style>
.advert {
width: 450px;
height: 100px;
line-height: 100px;
background-color: #ff0;
text-align: center;
border: 5px dashed red;
font-size: 60px;
}
</style>
<div class = 'advert' hidden > <!-- домашка -->
RECLAMA
</div>
<script>
let advert = document.querySelector('.advert');
// advert.hidden = true;
advert.hidden = false;
</script>
<ul class = 'phones'>
<li data-price = '100'>
iphone effdw233
</li>
<li data-price = '80'>
samsung fwsd232
</li>
<li data-price = '50'>
nokia 3311
</li>
</ul>
<script>
let phones = document.querySelectorAll('.phones li');
for (let phoneLi of phones) {
console.log('price', phoneLi.dataset.price)
}
</script>
<style>
.large {
font-size: 60px;
}
.red {
color: red;
}
</style>
<!-- <p class = 'large red'>
some text
</p> -->
<p id = 'someText'>
some text
</p>
<script>
let someText = document.getElementById('someText');
// someText.className = 'large red';
// someText.className = 'large';
// someText.className += ' red';
someText.classList.add('large');
someText.classList.add('red');
someText.classList.remove('red');
someText.classList.toggle('red'); /* туда-сюда */
someText.classList.contains('red'); /* проверка возвращает булевое значение */
</script>
<!-- создание элементов-->
<ul class = 'prod'>
<li class = prod-item>morkov</li>
<li class = prod-item>luk</li>
<li class = prod-item>potato</li>
</ul>
<script>
let prod = document.querySelector('.prod');
let newProd = document.createElement('LI');
// newProd.textContent = 'pepper'; /* ILI */
newProd.innerHTML = 'pepper'; /* ili PARSIT STROKU */
prod.append(newProd);
prod.insertAdjacentHTML('beforeEnd', '<li class = "prod-item">kabage<li>');
</script>
</body>
</html>