@Enmanuel-Otero-Montano
Posted
Hello Aurel!
I am going to leave you your code modified to achieve the same functionality but with a for loop and using the querySelectorAll as you had in mind. I just added the loop and removed the listener events for the buttons and also removed the buttons that were located by the "id"
const submitBtn = document.getElementById('submitBtn');
const cardItems = document.querySelector('.card-items');
const cardThankYou = document.querySelector('.card-thank-you');
const ratingButtons = document.querySelectorAll('.card-thank-you');
submitBtn.disabled = true;
submitBtn.onclick = () => {
cardItems.style.display = 'none';
cardThankYou.style.display = 'flex';
};
const allBtns = document.querySelectorAll('.ratingBtn');
const span = document.getElementsByTagName('span')[0];
for (let btn of allBtns) {
btn.addEventListener('click', () => {
span.innerHTML = btn.innerHTML;
submitBtn.disabled = false;
});
}
I would like you to try it and tell me if it works correctly for you.
Cheers!
Marked as helpful
@Aur71
Posted
@Enmanuel-Otero-Montano Works well, thanks
@Enmanuel-Otero-Montano
Posted
@Aur71 Looks to me like you're going to have to remove the classes to remove the button colors, add that.