-
Notifications
You must be signed in to change notification settings - Fork 0
/
DOM_eventos.html
executable file
·50 lines (47 loc) · 1.23 KB
/
DOM_eventos.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
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Eventos DOM</title>
<style>
#area{
font: normal 20pt Arial;
background: seagreen;
color: white;
width: 200px;
height: 200px;
line-height: 200px;
text-align: center;
}
</style>
</head>
<body>
<div id="area">
<!--CHAMANDO AS FUNÇÕES NO HTML:-->
<!-- onclick="clicar()"
onmouseenter="entrar()"
onmouseout="sair()"-->
Interaja...
</div>
<script>
var a = document.getElementById("area")
//EXISTE UMA OUTRA FORMA DE FAZER AO INVÉS DE CHAMAR
//AS FUNÇÕES NO HTML:
a.addEventListener('click', clicar)
a.addEventListener('mouseenter', entrar)
a.addEventListener('mouseout', sair)
function clicar(){
a.innerText = "Clicou!"
a.style.background = "red"
}
function entrar(){
a.innerText = "Entrou"
}
function sair(){
a.innerText = "Saiu"
a.style.background = "seagreen"
}
</script>
</body>
</html>