+ -
当前位置:首页 → 问答吧 → 关于$(this)的问题

关于$(this)的问题

时间:2009-12-15

来源:互联网

function removeAddr(e,id) {
if (confirm('你确定要删除这个地址吧?'))
{
$.ajax({
url : BASEURL+'order/updateAddrStatus',
type : 'post',
data : {id:id},
dataType : 'text',
beforeSend:function(){
$('#loadMask').show();
},
complete:function(){
$('#loadMask').hide();
},
success : function(msg){
e.closest('tr').remove();
}
});
} else {
return false;
}
}

 <a title="删除" onclick="removeAddr($(this),{[$address[s].id]})">删除</a>
这样$(this)在success的function里面有效的。
-------------------------------------------------------------------------------------------------------------------
$('.del').click(function(){
if (confirm('你确定要删除这个地址吧?'))
{
$id = $(this).attr('title');          //在这里$(this)还是有效的
$.ajax({
url : BASEURL+'order/updateAddrStatus',
type : 'post',
data : {id:$id},
dataType : 'text',
beforeSend:function(){
$('#loadMask').show();
},
complete:function(){
$('#loadMask').hide();
},
success : function(msg){
$(this).closest('tr').remove();      //在这里$(this)是无效的
}
});
} else {
return false;
}
});

 <a title="删除" title="{[$address[s].id]}">删除</a>
    在这里$(this)在success的function里是无效的
-----------------------------------------------------------------------------------------------------------------
请问各位高手我的问题出在哪里呢?

作者: zhuzuoling   发布时间: 2009-12-15

  就没有个回帖

作者: zhuzuoling   发布时间: 2009-12-27

看不懂             大家帮忙顶一下


_____________________________
TaylorMade R9 Fairway Wood,TaylorMade R9 Driver,TaylorMade R9 Irons,Ping G15 DriverTitleist AP2 Irons

作者: banghao123   发布时间: 2009-12-27