forked from romarpla/cursoFrontEnd
-
Notifications
You must be signed in to change notification settings - Fork 964
/
3.-navegador.js
50 lines (34 loc) · 985 Bytes
/
3.-navegador.js
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
//Encontrar elementos de HTML
const titulo = document.getElementById("titulo");
const parrafo = document.getElementsByTagName("p");
const links = document.getElementsByClassName("links");
//Cambiar valores de HTML
titulo.innerHTML = "Titulo cambiado";
document.getElementById("demo").innerHTML = 'The text in first paragraph (index 0) is: ' + parrafo[0].innerHTML;
links[0].href = "google.com";
//Cambiar estilos
titulo.style.color = "red"
//Eventos
function cambiarTexto(obj) {
obj.innerHTML = "Texto clickeado"
}
function mOver(obj) {
obj.innerHTML = "Mouse over now"
}
function mOut(obj) {
obj.innerHTML = "Mouse out"
}
function mDown(obj) {
obj.style.backgroundColor = "#1ec5e5";
obj.innerHTML = "sueltame";
}
function mUp(obj) {
obj.style.backgroundColor="#D94A38";
obj.innerHTML="gracias";
}
//addEventListener
const boton = document.getElementById("boton");
boton.addEventListener("click", alerta)
function alerta() {
alert("alerta");
}