scrimba
Frontend Career Path
Essential JavaScript concepts
Cookie Consent
Disable the close button
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

AboutCommentsNotes
Disable the close button
Expand for more info
index.js
run
preview
console
const modal = document.getElementById('modal')
const modalCloseBtn = document.getElementById('modal-close-btn')
const consentForm = document.getElementById('consent-form')
const modalText = document.getElementById('modal-text')

setTimeout(function(){
modal.style.display = 'inline'
}, 1500)

modalCloseBtn.addEventListener('click', function(){
modal.style.display = 'none'
})

consentForm.addEventListener('submit', function(e){
e.preventDefault()

const consentFormData = new FormData(consentForm)
const fullName = consentFormData.get('fullName')

modalText.innerHTML = `
<div class="modal-inner-loading">
<img src="images/loading.svg" class="loading">
<p id="upload-text">Uploading your data to the dark web...</p>
</div>`

setTimeout(function(){
document.getElementById('upload-text').innerText = `
Making the sale...`
}, 1500)

/*
Challenge:
1. Make the button that closes the modal disabled.
2. Make that button become usable when the final
modal message has been displayed to the user.
*/

setTimeout(function(){
document.getElementById('modal-inner').innerHTML = `
<h2>Thanks <span class="modal-display-name">${fullName}</span>, you sucker! </h2>
<p>We just sold the rights to your eternal soul.</p>
<div class="idiot-gif">
<img src="images/pirate.gif">
</div>
`
}, 3000)

})
Console
/index.html
-3:09