簡體   English   中英

如何通過ajax jquery設置di​​v標簽的屬性值

[英]how to set attribute value of div tag through ajax jquery

我想設置屬性“數據評級”的值。 它將使用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();

}
});`

如果有人可以,請幫助我。

$("#fieldId").attr("data-rating","value want to set");
$('#objectID').attr('data-rating', 'your value')

內部成功功能

success : function(data) {

 $('#yourdivid').attr('data-rating','value from the response');
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM