2022-2023/1NSI/08_Interaction_web/codes/popup/2E_popup.js
Bertrand Benjamin 8282f2ad6e
All checks were successful
continuous-integration/drone/push Build is passing
Feat(NSI): exercice de lecture d'évènements
2023-03-04 17:52:58 +01:00

47 lines
1.3 KiB
JavaScript

const popup = document.getElementById('popup');
function closeSection1 () {
let section = document.getElementById('section1');
section.style.display = "none";
popup.classList.remove('hidden');
}
document.getElementById("close-section1").addEventListener('click', closeSection1)
function closeSection2 () {
let section = document.getElementById('section2');
popup.classList.remove('hidden');
let p = document.createElement('p')
p.innerHTML = "Je disparais pas!"
section.appendChild(p)
}
document.getElementById("close-section2").addEventListener('click', closeSection2)
let compteur = 0
function closeSection3 () {
let popup = document.getElementById('popup');
let section = document.getElementById('section3');
if (compteur > 2) {
section.style.display = "none";
popup.classList.remove('hidden');
} else {
compteur = compteur + 1;
popup.classList.remove('hidden');
let p = document.createElement('p')
p.innerHTML = "Restez! Je vous fait une promo de 10%!"
section.appendChild(p)
}
}
document.getElementById("close-section3").addEventListener('click', closeSection3)
const closePopupLink = document.getElementById('close-popup');
closePopupLink.addEventListener('click', (event) => {
event.preventDefault();
popup.classList.add('hidden');
});