-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
33 lines (26 loc) · 892 Bytes
/
Copy pathmain.js
File metadata and controls
33 lines (26 loc) · 892 Bytes
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
var miImage = document.querySelector('img');
miImage.onclick = function() {
var miSrc = miImage.getAttribute('src');
if(miSrc === 'images/GirlPower2.jpg') {
miImage.setAttribute('src','images/girlcan.jpg');
} else {
miImage.setAttribute ('src', 'images/GirlPower2.jpg');
}
}
var miBoton = document.querySelector('button');
var miTitulo = document.querySelector( 'h1');
function estableceNombreUsuario() {
var miNombre = prompt('Por favor, ingresa tu nombre.');
localStorage.setItem('nombre', miNombre);
miTitulo.textContent = 'Girl Power is,' + miNombre;
}
if (!localStorage.getItem('nombre')) {
estableceNombreUsuario();
}
else {
var nombreAlmacenado = localStorage.getItem('nombre');
miTitulo.textContent = 'Girl Power is,' + nombreAlmacenado;
}
miBoton.onclick = function() {
estableceNombreUsuario();
}