3

利用伪元素、:checked、~兄弟选择器实现5星评分

 1 year ago
source link: https://xushanxiang.com/star-rating.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

利用伪元素、:checked、~兄弟选择器实现5星评分

作者: xusx 分类: Web 发布时间: 2022-05-21 18:12 浏览:10

效果如下:

star-rating.gif

关键代码:

rate.value=parseInt(Array.from(document.querySelectorAll(`input[name='rating']`)).filter(e=>e.checked)[0].value) 

详情请看:演示

如果觉得我的文章对您有用,请随意赞赏。您的支持将鼓励我继续创作!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK