-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
28 lines (24 loc) · 961 Bytes
/
script.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
function toggleMode() {
const html=document.documentElement;
// aqui fizemos a função toogle debaixos dos panos
// if (html.classList.contains('light')) {
// html.classList.remove('light');
// }else
// {
// html.classList.add('light');
// }
//faz a verificação se exite class remove senão add a class
html.classList.toggle('light');
// pegar a tag img e subistituir
const image = document.querySelector('#profile img');
if (html.classList.contains('light')) {
// se tiver a class light colocar outra imagem
image.setAttribute('src','./assets/avatar-miro.png');
image.setAttribute('alt','foto de Francisco usando o preto');
}else
{
// senão tiver a class manter a imagem
image.setAttribute('src', './assets/avatar-light-miro.png');
image.setAttribute('alt',' Foto de Francisco na mentoria da open-source Angola');
}
}