Submitted almost 2 years ago
Interactive rating component, responsive and using JS
@Rafael-Urei
Design comparison
SolutionDesign
Solution retrospective
The most difficult part was the JS, I wanna know if there's a easiest way to make this transition of style between buttons after you click them, making them selected.
Community feedback
- @yishak621Posted almost 2 years ago
I see in ur code that u replace the whole document by js but instead u design two cards in same containor and use js to toggle from rating card to result card ...
//Submit btn click event submitBtn.addEventListener('click', () => { callBack(); const newArray = [...eachBtns]; //spread operator to convert them to array newArray.forEach((btn) => { //checking if the user click on rating btn-at least one of it makes it true if (btn.classList.contains('btn-active')) { ratingCard.classList.add('hidden'); selectedCard.classList.remove('hidden'); home.classList.remove('hidden'); errorMessage.classList.remove('error-active'); } else if (!selectedCard.classList.contains('hidden')) { errorMessage.classList.remove('error-active'); } else { errorMessage.classList.add('error-active'); function hideError() { errorMessage.classList.remove('error-active'); } setTimeout(hideError, 2000); } }); });
Marked as helpful0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord