我有这个html:
<a href="#" class="cancel" id="cancel_3'">cancel</a>
当用户单击取消时,我想删除超链接,并且我想用图像替换它,即
$.ajax({
context:this,
type: "POST",
url: "actions/cancel.php",
data: "id=" + the_id,
cache: false,
success: function() {
$(this).remove;
// add image
谢谢:))
最佳答案
尝试:
success: function() {
$( "a#cancel_3" ).replaceWith( "<img...>" );
}
您必须在replaceWith 函数中填写您想要替换链接的内容。只是我使用的占位符。
关于javascript - ajax请求后替换其他东西?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4973615/