java - 如何通过ajax jquery设置di​​v标签的属性值

标签 java 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");

关于java - 如何通过ajax jquery设置di​​v标签的属性值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12475643/

相关文章:

javascript - 使用jquery动态创建div会导致语法错误

javascript - 使用 jQuery 使用 CSS 为文本着色

java - 无法在 Selenium Webdriver 中找到 iframe

java - 重复和android服务,完成后自动调用

java - maven "catch"执行 - 对失败的构建执行清理

javascript - AJAX XML回复节点值迭代

java - 使用 Selenium 测试的 Vaadin 上传文件路径

php - 使用 ajax (jquery) 分页 - 大数据库

javascript - $这会被快速连续的点击覆盖

javascript - jQuery 动画到顶部功能不起作用