我只是不能得到这个(很简单)功能正常工作,父母()似乎并没有找到我想要的股利,并淡出出来:(为什么jQuery的父母()找不到我的元素?
$('.deleteButton').click(function() {
var img = $(this).attr('href');
img = "../"+img;
var answer = confirm('Are you sure you want to delete this item? (This cannot be undone!)');
if (answer) {
$.ajax({
url: 'scripts/deletePhoto.php',
data: 'img='+img,
type: 'POST',
mode: 'abort',
success: function(){
$(this).parents("div.photo").fadeOut('fast');
}
});
}
return false;
});
HTML
<div class="photo">
<img alt="" src="../static/images/photos/tmp/1.jpg">
<div class="overlay" style="opacity: 0;">
<p class="process success message">
<a href="process_photo.php?img=../static/images/photos/tmp/1.jpg">Process this photo</a>
</p>
<p class="delete error message">
<a href="../static/images/photos/tmp/1.jpg" class="deleteButton">Delete image</a></p>
</div>
</div>
我试过$(this).parents(".photo").fadeOut('fast');
和$(this).cloest("div.photo").fadeOut('fast');
但没有什么是连接:(
$(this)将用于ajax函数。不是点击处理程序 – 2013-03-11 12:53:27
啊!谢谢,拉维! – 2013-03-11 12:53:50