我使用jquery raty plugin,有click event裏面我是用送的評價數據,然後從數據庫返回新的評級,但我不能想出如何更新返回的評價,我的代碼:如何更新RATY值
$('.starrating').raty({
number:10,
score: function() {
return $(this).attr('data-rating');
},
click: function(score, evt) {
var contentid = $(this).attr('id');
$.post('/main/rating.php',{score:score, contentid:contentid },
function(data){
//alert(data+' Score = '+score);
$(this).data('rating',2);
});
}
});
我嘗試了下面但沒有成功;
$(this).data('rating',2);
感謝您的任何幫助。
通過設置'$ .fn.data'你只設置jQuery的數據緩存鏈接元素。甚至沒有真正的數據屬性 – 2013-03-26 13:58:25