-
Notifications
You must be signed in to change notification settings - Fork 0
/
js62my.html
60 lines (41 loc) · 1.16 KB
/
js62my.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<!-- <style>
p:nth-child(even) {
color: hotpink;
}
</style> -->
</head>
<body>
<p>Абзац 1</p>
<p>Абзац 2</p>
<p>Абзац 3</p>
<p>Абзац 4</p>
<p>Абзац 5</p>
<p>Абзац 6</p>
<p>Абзац 7</p>
<p>Абзац 8</p>
<p>Абзац 9</p>
<p>Абзац 10</p>
<button id="but" onclick="change()">Изменить</button>
<script>
// querySelectorAll Выбор по селекторам CSS
function change() {
let s1 = document.querySelectorAll('p:nth-child(even)');
for (i=0; i<s1.length; i++) {
s1[i].innerHTML = `Параграф ${i+1}`;
s1[i].style.cssText = `
border: 1px solid #f00;
background: blue;
color: white;
`;
}
}
</script>
</body>
</html>