鼠标滑过不适合多行,比较乱的感觉,建议只采取点击的方式,可参考
实现填报中的动态星星评分效果.cpt
$("td").click(function() {
//鼠标点击单元格,即选中星星时
var $td = $(this);
var rownum = parseInt($td.attr('row'));
var col = parseInt($td.attr('col'));
if (col > 0 && col < 6) {
//从第2列到第6列,对应的col为1-5
for (var i = 1; i <= col; i++) {
$("td[row="+ rownum +"][col=" + i + "]").css('background', "url(/webroot/help/picture/on.png) no-repeat 50% 50%");
};
//在此单元格之前的星星为选中状态
for (var i = col + 1; i < 6; i++) {
$("td[row="+ rownum +"][col=" + i + "]").css('background', "url(/webroot/help/picture/off.png) no-repeat 50% 50%");
};
var score = contentPane.curLGP.getCellValue(6,rownum) * 1;
if (score >= 1) {
for (var i = 1; i <= score; i++) {
$("td[row="+ rownum +"][col=" + i + "]").css('background', "url(/webroot/help/picture/on.png) no-repeat 50% 50%");
};
//如果上次评分了,那么设置评分的星星为选中状态
}
var score = parseInt($td.attr('cv'));
contentPane.setCellValue(6,rownum,score);
}
//点击选中星星,给G2单元格设置值
})