请问各位大佬 fieldset 怎么获取其中选中的值?

傲雪_ 2018-02-07 03:52:49
<div class="star-rating">
<fieldset id="test">
<input type="radio" id="star5" name="rating" value="5" /><label for="star5" title="Outstanding" value="5">5 stars</label>
<input type="radio" id="star4" name="rating" value="4" /><label for="star4" title="Very Good" value="4">4 stars</label>
<input type="radio" id="star3" name="rating" value="3" /><label for="star3" title="Good" value="3">3 stars</label>
<input type="radio" id="star2" name="rating" value="2" /><label for="star2" title="Poor" value="2">2 stars</label>
<input type="radio" id="star1" name="rating" value="1" /><label for="star1" title="Very Poor" value="1">1 star</label>
</fieldset>
</div>
请问一下怎么获取选中的值?
...全文
1358 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Hello World, 2018-02-08
  • 打赏
  • 举报
回复
这个取值的方法评分插件应该是有的
天际的海浪 2018-02-07
  • 打赏
  • 举报
回复
$("input[name=rating]:checked").val()
似梦飞花 2018-02-07
  • 打赏
  • 举报
回复

document.getElementById('test').onclick=function(){
     var values=[].slice.call(document.querySelectorAll('#test>:checked')).map(function(item){
         return item.value;
     });
     console.log(values);
 }
傲雪_ 2018-02-07
  • 打赏
  • 举报
回复
这样的

87,904

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧