更新时间:2023-01-17 15:30:15
使用ajax的上下文选项:
Use context option of ajax:
$(".descWrapper h1 a ").on("click", function (e) {
e.preventDefault();
$.ajax({
context:this,
url: 'ajaxify/gallery.php',
type: "get",
data: "id=" + $(this).attr('href'),
beforeSend: function () {
},
success: function (data) {
//now 'this' here refers to the clicked link
$(this).parents(".album").next(".gallery").html(data);
},
error: function (xhr, status, errorThrown) {
alert();
}
});
});