我想设置属性'data-rating'的值。它将使用Ajax。
<div id="fixed_<s:property value="messageId"/>" **data-rating=**"<%=averageScore%>"></div> from ajax function though jquery that is as below :
`
$.ajax({
type : "POST",
cache:false,
url : '<s:url action="ratingStatus"/>',
dataType: "text",
data : 'score=' +score+'&messageId='+<s:property value="messageId"/>+'&categoryId='+<s:property value="categoryId"/>+'&threadId='+<s:property value="threadId"/>,
success : function(data) {
alert("inside Success...");
//here i want to set div attribute(data-rating) value from action class response that i have made...
//location.reload();
}
});`
如果有人可以帮助我......
答案 0 :(得分:4)
$("#fieldId").attr("data-rating","value want to set");
答案 1 :(得分:1)
$('#objectID').attr('data-rating', 'your value')
答案 2 :(得分:1)
成功功能
success : function(data) {
$('#yourdivid').attr('data-rating','value from the response');
}