scrimba
Frontend Career Path
Essential JavaScript concepts
Cookie Consent
Aside: Disabling elements
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
Aside: Disabling elements
Expand for more info
index.js
run
preview
console
const decrement = document.getElementById('decrement')
const increment = document.getElementById('increment')
const quantityDisplay = document.getElementById('quantity-display')
const cartBtn = document.getElementById('cartBtn')

let quantity = 0

decrement.addEventListener('click', function(){
quantity--
quantityDisplay.innerText = quantity
})

increment.addEventListener('click', function(){
quantity ++
quantityDisplay.innerText = quantity
})

cartBtn.addEventListener('click', function(){
console.log(`Your order for ${quantity} pairs of shoes is being processed`)
/*
Challenge:
1. Disable the 'Add to Cart' button when
quantity is at zero. Remember: quantity
will be at zero when the page loads!
*/
})


Console
/index.html
-6:05