Тёмный

Frontend Machine Coding Interview | Star Rating Component | HTML | CSS | Javascript 

Vijay Bhati
Подписаться 996
Просмотров 4 тыс.
50% 1

Опубликовано:

 

18 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 13   
@Truthwithfactss
@Truthwithfactss 5 месяцев назад
Nice and clear explanation...
@Vijay_Bhati
@Vijay_Bhati 5 месяцев назад
I am glad you liked it 😊
@rishabhkansal5811
@rishabhkansal5811 7 месяцев назад
Its great!! 😊 Thanks so much. Please make more content on machine coding questions with HTML, CSS, JS
@Vijay_Bhati
@Vijay_Bhati 7 месяцев назад
Frontend Machine Coding Interview Problems ru-vid.com/group/PLBygUld3s6x8sI_H8UYROVMIVcuxUre1e
@opinformation2233
@opinformation2233 Год назад
Its good bro keeping doing more
@Vijay_Bhati
@Vijay_Bhati Год назад
I am happy you find the content useful 😊. For more such content Subscribe to the channel and Here is the playlist of Frontend Machine Coding Interview Problems ru-vid.com/group/PLBygUld3s6x8sI_H8UYROVMIVcuxUre1e
@ishanksainger2627
@ishanksainger2627 10 месяцев назад
Thanks for the code, I did some modifications. let starRating = document.querySelectorAll(".star"); let ratingCount = document.getElementById("count"); starRating.forEach((star, index) => { star.addEventListener("click", () => { if (star.classList.contains("active")) { for (let i = starRating.length-1; i > index; i--) { starRating[i].classList.remove("active"); } } else { for (let i = 0; i < index + 1; i++) { starRating[i].classList.add("active"); } } let activeStars = document.querySelectorAll(".star.active").length; ratingCount.innerHTML = `Rating Count : ${activeStars}`; }); }); starRating.forEach((star, index) => { star.addEventListener("mouseover", () => { for (let i = 0; i < index + 1; i++) { starRating[i].classList.add("hovered"); } }); }); starRating.forEach((star, index) => { star.addEventListener("mouseout", () => { for (let i = 0; i < index + 1; i++) { starRating[i].classList.remove("hovered"); } }); });
@Vijay_Bhati
@Vijay_Bhati Год назад
UI :- rating-component-normal.netlify.app/ Code :- github.com/vj98/Frontend-Machine-Coding/tree/main/rating-component
@gamingnatu3263
@gamingnatu3263 2 месяца назад
Its very use full
@rayyanabdulwajid7681
@rayyanabdulwajid7681 7 месяцев назад
This is possible even without javascript, i saw a code on codepen. Thanks anyway for the knowledge
@Vijay_Bhati
@Vijay_Bhati 7 месяцев назад
Okay, but you must understand how it works behind the scenes in any form and with any method.
@rayyanabdulwajid7681
@rayyanabdulwajid7681 7 месяцев назад
@@Vijay_Bhati You're right
@just_a_living_being
@just_a_living_being Год назад
Thank you for the video, this is my solution just modified your solution and added event delegation to avoid unnecessary click and mouseover events. const starContainer = document.getElementById('star-container') const stars = document.querySelectorAll('.star') const count = document.getElementById('count') let filled = 0 starContainer.addEventListener('click', e => { if (e.target.matches('span')) { const rating = e.target.dataset.rating for (let j = 0; j < filled; j++) { stars[j].classList.remove('star-filled') } for (let i = 0; i < rating; i++) { stars[i].classList.add('star-filled') } filled = rating count.innerText = `Rating Count : ${filled}` } }) starContainer.addEventListener('mouseover', e => { if (e.target.matches('span')) { const rating = e.target.dataset.rating for (let j = 0; j < filled; j++) { stars[j].classList.remove('star-filled') } for (let i = 0; i < rating; i++) { stars[i].classList.add('star-filled') } } }) starContainer.addEventListener('mouseleave', e => { for (let j = 0; j < 5; j++) { stars[j].classList.remove('star-filled') } for (let i = 0; i < filled; i++) { stars[i].classList.add('star-filled') } })
Далее
Build this JS calculator in 15 minutes! 🖩
15:20
Просмотров 550 тыс.
5 Mini JavaScript Projects - For Beginners
1:45:09
Просмотров 80 тыс.
How I'd Learn Web Development (If I Could Start Over)
6:55