我无法从行中的链接中选择一行表格。单击链接时,我需要该行消失。我目前的代码如下......
function show_docs(){
$('.file_holder5').html("");
var id=$('.useri').val();
var data="user_id="+id;
$.ajax({
type:"POST",
url:"admin_includes/get_all_files.php",
data:data,
success:function(html){
var split_html=html.split("*^*");
var split_ht_count=split_html.length-1;
var tb2="<table class='doc_table' width='100%'>";
tb2+="<tr><th>Upload Date</th><th>File</th><th>Description</th><th>Actions</th><th> </th></tr>";
var el;
if(split_ht_count==0)
{
tb2+="</table>";
tb2+="<p>There are currently no files in your library.</p>";
}
else
{
for(var rx=0;rx<split_ht_count;rx++)
{
el=split_html[rx].split("|");
tb2+="<tr class='file_row' data-link2='"+el[0]+"'><td>"+el[2]+"</td><td>"+el[1]+"</td><td>"+el[3]+"</td><td><a class='view_f' href='sym.php?doc_id="+el[0]+"'>View File</a></td><td><a class='del_f' href='javascript:void(0)' data-link='"+el[0]+"'>Delete File</a></td></tr>";
}
tb2+="</table>";
}//end else
$(tb2).appendTo('.file_holder5');
StripeRows();
}
});//end ajax
}
//-----------------delete_files---------------------
$(document).on('click', '.del_f', function(){
var file_id=$(this).data('link');
var data="file_id="+file_id+"&user="+$('.useri').val();
$.ajax({
type:"POST",
url:"admin_includes/delete_filex.php",
data:data,
context:this,
success:function(html){
if(html=="1")
{
alert("The selected file is needed for a current job. To delete this file, delete the file from the current appointment in the Current Jobs page.");
return;
}
else
{
//get rid of listing
$('tr.file_row').data('link2', file_id).remove();
}
}
});//end ajax
});
显然,这是我选择导致我出现问题的当前行的方法。
答案 0 :(得分:3)
尝试删除行时尝试使用此代码:
$(this).closest("tr").remove();
答案 1 :(得分:0)
请参阅jsFiddle
$('.deleteRowButton').click(function () {
$(this).parents('tr').first().remove();
});