-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstyleCSS.html
43 lines (36 loc) · 1.19 KB
/
styleCSS.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.highlight {
color: red;
}
</style>
<title>Document</title>
</head>
<body>
<h1 id="title">Título da página</h1>
<button id="change-color"> Alterar cor </button>
<script>
/* ALTERANDO O ESTILO DE UM ELMENTO
const titleEL = document.querySelector("#title")
const buttonEl = document.querySelector('#change-color')
buttonEl.addEventListener("click", () => {
titleEL.style = "color: red; font-size: 55px"
}) */
// ALTERANDO A CLASSE DE UM ELEMENTO
const titleEL = document.querySelector("#title")
const buttonEl = document.querySelector('#change-color')
buttonEl.addEventListener("click", () => {
/* if (titleEL.classList.contains("highlight")) {
titleEL.classList.remove("highlight") }
else {
titleEL.classList.add("highlight") }
*/
titleEL.classList.toggle("highlight")
})
</script>
</body>
</html>