-6
$('.deleteImage a').click(function() {

alert('Delete this?');
 $.ajax({
    type:'GET',
    url: this,
    success: function(){
    $(this).hide('slow');
    }
    });


return false;
});
4

2 回答 2

1

使用闭包:

$('.deleteImage a').click(function () {

    alert('Delete this?');
    (function (self) {
        $.ajax({
            type: 'GET',
            url: self,//strange url!!!
            success: function () {
                $(self).hide('slow');
            }
        });
    })(this);

    return false;
});
于 2013-05-06T18:59:11.540 回答
0
$('.deleteImage a').click(function() {

var thiz = $(this); // references the '.deleteImage a'

alert('Delete this?');
 $.ajax({
    type:'GET',
    url: this,
    success: function(){
        thiz.hide('slow'); //$(this) references to the ajax, use our thiz to reference to '.deleteImage a'
    }
    });


return false;
});

阅读评论

于 2013-05-06T18:59:51.197 回答