[英]how to set attribute value of div tag through ajax jquery
I want to set value of attribute 'data-rating'. 我想设置属性“数据评级”的值。 It will use Ajax.
它将使用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();
}
});`
Please help me if any one can.... 如果有人可以,请帮助我。
$("#fieldId").attr("data-rating","value want to set");
$('#objectID').attr('data-rating', 'your value')
Inside your success function 内部成功功能
success : function(data) {
$('#yourdivid').attr('data-rating','value from the response');
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.