我在页面上使用带有 5 个评级选项的 jquery 比率。我想统计score
所有 5 个评分。我已经给每个评级它自己的 ID#targetKeep1
#targetKeep2
等...并将其更改scoreName
为唯一的。我想以某种方式将所有分数加起来并显示出来。我该怎么做呢?
会是这样的function(score, evt) { var answer1 = score; var answer2 = score; var answer3 = score; etc.. }
吗?
<script type="text/javascript">
$(function() {
$.fn.raty.defaults.path = 'img/';
$('#targetKeep1').raty({
cancel : false,
width : 310,
number : 6,
target : '#targetKeep1-hint',
single : true,
hints : ['0', '1', '2', '3', '4' , '5'],
targetKeep : true,
scoreName : 'answer1',
click: function(score, evt) {
alert('ID: ' + $(this).attr('id') + "\nscore: " + score + "\nevent: " + evt);
}
});
});
$(function() {
$.fn.raty.defaults.path = 'img/';
$('#targetKeep2').raty({
cancel : false,
width : 310,
number : 6,
target : '#targetKeep2-hint',
single : true,
hints : ['0', '1', '2', '3', '4' , '5'],
targetKeep : true,
scoreName : 'answer2',
});
});