Latest solutions
Latest comments
- @younesadjoudj@younesadjoudj
JS code Updated:
let primaryScreen = document.querySelector(".screen-primary"); let thankYouScreen = document.querySelector(".screen-thank-you"); let rate = document.querySelectorAll(".rate"); let rateSelected = document.querySelector('.rate-selected'); let lastClickedRate = null; rateSelected.textContent = ""; rate.forEach((div) => { div.addEventListener('click', function() { if (lastClickedRate) { lastClickedRate.style.backgroundColor = 'hsl(217, 10%, 35%)'; // Restore the initial style of the last clicked div lastClickedRate.style.color = "hsl(217, 12%, 63%)"; } this.style.backgroundColor = 'hsl(25, 97%, 53%)'; // Change the style of the currently clicked div this.style.color = "#fff"; lastClickedRate = this; // Updates reference to last clicked div rateSelected.textContent = div.dataset.value; // save the data value of the selected rate }); }); btn.addEventListener("click", (e) => { e.preventDefault(); if(rateSelected.textContent == "") { window.alert("Please choose an option and try again"); } else { primaryScreen.style.display = "none"; thankYouScreen.style.display = "initial"; } } );
- @Ajayfrizzy@younesadjoudj
@Ajayfrizzy Great job! I think better to styling with a mobile-first approach.
- @BekstersLab@younesadjoudj
@BekstersLab Hi! Very nice work. For the spacing between sale/full prices, try a display: flex on the parent element, and add a gap css property (for exemple: gap: 2rem;). And don't forget to align the items on the secondary axis so that the full price is positioned in the middele.
.prices p { display: flex; align-items: center; gap: 2rem; }