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'); });