本文介绍了jQuery-从数据库中删除表行后将其删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从数据库中成功删除已删除的表行后,我尝试将其删除,但它不起作用.这是我的代码.
I'm try to remove the deleted table row after it's been successfully deleted from the database but it not working. Here is my code.
这有效:
$('table td img.delete').click(function(){
if(confirm("Are you sure you want to permanently delete this?"))
$(this).parent().parent().remove();
}
});
这不起作用:
$('table td img.delete').click(function(){
if(confirm("Are you sure you want to permanently delete this?"))
$.get('cfc/action.cfc?method=deleteLetter&returnformat=plain', {id: $(this).attr('id')},
function(data){
if(data.replace(/^\s+|\s+$/g, '')==='ok'){
$(this).parent().parent().remove();
}
});
}
});
此记录在此处被删除,但表行仍保留.任何建议将不胜感激.
This record get deleted here but the table row remains. Any suggestion would be much appreciated.
谢谢!
推荐答案
$('table td img.delete').click(function(){
var currentRow = $(this);
if(confirm("Are you sure you want to permanently delete this?"))
$.get('cfc/action.cfc?method=deleteLetter&returnformat=plain', {id: $(this).attr('id')},
function(data){
if(data.replace(/^\s+|\s+$/g, '')==='ok'){
currentRow.parent().parent().remove();
}
});
}
});
这将起作用.
当您在匿名方法/函数中说这句话时,将向执行代码的那个方法或对象显示此",但是如果将$(this)分配给变量,则可以在任何地方使用它.
When you say this in anonymous method/function then "this" showing to that method or object where code is executed, But if you assign $(this) to variable then you can use it anywhere.
这篇关于jQuery-从数据库中删除表行后将其删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!