Design comparison
Solution retrospective
My first solution to the challenge that includes Javascript, and the JS part seems to behave weirdly. Open the DevTools > Console and click any rating number to see what I mean. If you know how to solve it, it would be much appreciated.
All feedbacks are wellcome, especially the JS one.
Community feedback
- @natashaplPosted about 2 years ago
Hi Trvan. Nice work! It looks like it's throwing an undefined because it's targeting both the input and the span inside of
.rating-btn
div. Adding theinput
to theconst ratingBtns
worked for me:const ratingBtns = document.querySelectorAll('.rating-btn input');
I hope this helps.
Marked as helpful1 - @trillioncluesPosted about 2 years ago
Hello Trvan! I guess you should try out Natasha's solution and see if it solves the bug. You seem to be targeting both elements.
Alternatively, you could just assign a class to the input element alone(and not together with the span tag) and then use the querySelectorAll to call them.
I hope this works for you.
2
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