效果图:
js以及图片地址 自行引入:
核心代码:
html:
<div class="clearfix" >
<span class="f-l f-15 va-m">速度星级:</span>
<div id="star-1" class="star-bar size-M f-l mr-10 va-m"></div>
<strong id="result-1" class="f-l va-m"></strong>
</div>
<div class="clearfix" >
<span class="f-l f-15 va-m">质量星级:</span>
<div id="star-2" class="star-bar size-M f-l mr-10 va-m"></div>
<strong id="result-2" class="f-l va-m"></strong>
</div>
<div class="clearfix">
<span class="f-l f-15 va-m">态度星级:</span>
<div id="star-3" class="star-bar size-M f-l mr-10 va-m"></div>
<strong id="result-3" class="f-l va-m"></strong>
</div>
js:
$(function(){
$("#star-1").raty({
hints: ['1','2', '3', '4', '5'],//自定义分数
starOff: 'iconpic-star-S-default.png',//默认灰色星星
starOn: 'iconpic-star-S.png',//黄色星星
path: '${tPath}/static/h-ui/images/star',//可以是相对路径
number: 5,//星星数量,要和hints数组对应
showHalf: true,
targetKeep : true,
click: function (score, evt) {//点击事件
//第一种方式:直接取值
$("#result-1").html('你的评分是'+score+'分');
}
});
$("#star-2").raty({
hints: ['1','2', '3', '4', '5'],//自定义分数
starOff: 'iconpic-star-S-default.png',//默认灰色星星
starOn: 'iconpic-star-S.png',//黄色星星
path: '${tPath}/static/h-ui/images/star',//可以是相对路径
number: 5,//星星数量,要和hints数组对应
showHalf: true,
targetKeep : true,
click: function (score, evt) {//点击事件
//第一种方式:直接取值
$("#result-2").html('你的评分是'+score+'分');
}
});
$("#star-3").raty({
hints: ['1','2', '3', '4', '5'],//自定义分数
starOff: 'iconpic-star-S-default.png',//默认灰色星星
starOn: 'iconpic-star-S.png',//黄色星星
path: '${tPath}/static/h-ui/images/star',//可以是相对路径
number: 5,//星星数量,要和hints数组对应
showHalf: true,
targetKeep : true,
click: function (score, evt) {//点击事件
//第一种方式:直接取值
$("#result-3").html('你的评分是'+score+'分');
}
});
});
获取评分:$("#star-1").raty('score')
本文发布于:2024-01-30 16:09:55,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170660219721229.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |