如何删除 AJAX 查询的complete
函数中的列表元素<div class="image-?">...</div>
?$(this)
...?
<div class="edit-image-list">
@foreach (var image in Model.AttachedImages)
{
<div class="image-@image.Id">
<img width="180" height="180" src="data:image/jpeg;base64,@(Convert.ToBase64String(image.Data))" class="img-thumbnail" alt="Responsive image">
<a class="delete-image" data-id="@image.Id">Delete</a>
</div>
}
</div>
<script>
$(document).on('click', '.delete-image', function (e) {
e.preventDefault();
console.log($(this).data("id"));
$.ajax({
method: "POST",
url: "@Url.Action("DeleteImage","Forum")",
error: function () {
console.log('error');
},
data: { Id: $(this).data("id") },
complete: function () {
// How to delete class="image-?"
}
});
});
</script>
1条答案
按热度按时间uhry853o1#
对以
image
开头的div
使用通配符: