我只是不能得到這個(很簡單)功能正常工作,父母()似乎並沒有找到我想要的股利,並淡出出來:(爲什麼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