我正在使用jquery星级评级插件"Raty" https://github.com/wbotelhos/raty.我正在使用PHP从数据库生成结果集.这也包括得分.我想为每个评级组件设置分数属性.我怎样才能做到这一点?我正在使用这种语法来显示星星.
$('.stars_small').raty({
readOnly : true,
half : true,
score : 2,
space : false
});
<div class="stars_small"></div>
Run Code Online (Sandbox Code Playgroud)
在单个页面中有许多div,动态生成类"stars_small".我想为每个div设置"得分".
$('.stars_small').raty({
readOnly : true,
half : true,
score: function() {
return $(this).attr('data-rating');
}
space : false
});
Run Code Online (Sandbox Code Playgroud)
这对我来说很好.该插件在每添加一个文本框隐藏div有class="stars_small"
这样的
<div class="stars_small">
<input type="hidden" name="score" value="3.5" readonly="readonly">
</div>
Run Code Online (Sandbox Code Playgroud)
所以我只value使用来自数据库查询的数字设置属性.