-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathch4-innerthtmlex.html
More file actions
40 lines (32 loc) · 1.21 KB
/
Copy pathch4-innerthtmlex.html
File metadata and controls
40 lines (32 loc) · 1.21 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Exemplo de innerHTML</title>
<script>
/*
Todos oos objetos em JavaScript possuiem suas Proriedades
innerHTML é uma propriedade que representa o conteúdo de um elemento HTML
*/
function exemplo1() {
var target = document.getElementById("first");
var valorAtual = target.innerHTML;
console.log(valorAtual);
if(1<4){
target.innerHTML = "É possível alterar qualquer valor dentro de um elemento HTML utilizando a propriedade innerHTML. Inclusive qualquer tag dentro deste elemente também será alterado."
}
}
</script>
</head>
<body>
<h2>Condicionais Em JavaScript</h2>
<button id="activator" type="button">InnetHTML!</button>
<p id="first">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. <span>...</span>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Dog biscuits.</p>
<script>
document.getElementById("activator").onclick = function(){
exemplo1();
}
</script>
</body>
</html>