Design comparison
SolutionDesign
Solution retrospective
Any advice is appreciated. Help a brother grow!
Community feedback
- @Abdullahbutt3434Posted about 2 years ago
Hi @samuel, š, good job on completing this challenge! š I have a suggestion that might be helpful for you. you can use one class instead of id to data from all of these inputs using JS.
Your code:
<fieldset class="labels"> <input type="radio" name="rate" id="rate1" data="1"> <input type="radio" name="rate" id="rate2" data="2"> <input type="radio" name="rate" id="rate3" data="3"> <input type="radio" name="rate" id="rate4" data="4"> <input type="radio" name="rate" id="rate5" data="5"> </fieldset>
After changes
<fieldset class="labels"> <input type="radio" name="rate" class="ratingData" data="1"> <input type="radio" name="rate" class="ratingData" data="2"> <input type="radio" name="rate" class="ratingData" data="3"> <input type="radio" name="rate" class="ratingData" data="4"> <input type="radio" name="rate" class="ratingData" data="5"> </fieldset>
After this change, you can get data attributes with just a few lines of javascript code. const rating = document.querySelectorAll('.ratingData');
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