Responsive Inter Active Rating Component using Html , Css and js
Design comparison
Community feedback
- @opeyemi-codePosted about 2 years ago
Firstly, I'd like to congratulate you on taking part in this challenge. However, some issues need to be fixed in your work. I'd like to make some contributions regarding the challenge: *For the ratings, I'll suggest that you put them in a li element instead of a button. *For the selected number create a span element and an id that will hold the selected number. *for the Javascript side, create a global variable with the keyword 'let' and assign a value of zero to It. *To get the number that was selected, loop through the list items using a forEach array method and add an event listener to each one of them. After doing that pass the event (e) method as a parameter in that function, then use the e.currentTarget.textContent to get the value of the selected item and store it in the variable that was created earlier. Ex. Assume that the variable you created was named count. count = e.currentTarget.textContent; *After that, attach an event listener to the submit button. Inside the submit button, pass the value of the variable that holds the number to the span element that was created in the HTML file. I hope this will help. Good luck with it.
1 - @rox-stahlPosted about 2 years ago
Hi, I completed this a few days ago!! Try this: If this doesn't make sense, you can look at my code https://github.com/Roxanne-Stahl/challenge3
btns.forEach((btn) => { btn.addEventListener("click", () => { let rateId = e.target.id; const numberBtn = document.getElementById(rateId); numberBtn.classList.add(".btn-selected"); actualRating.innerHTML = numberBtn.innerHTML }) }) })
1
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