2009-12-04 32 views
0

使用变量在每次搜索我只提出包括像这样的变量的解决方案:$(“#DIV” + id)的jQuery的:在选择器

我需要删除的行。

var row = $(this).parent().parent().parent().find('tr#' + id).html(); 

我想使用“行”名称而不是“$(this)... remove();”

回答

4

使用.closest,它比所有那些链式父调用更安全,以防您更改将破坏代码的标记。

var row = $(this).closest('tr'); 
row.remove() 
+0

这工作,谢谢! – Norbert 2009-12-04 14:22:45

6

$('tr[name='+rowname+']').remove() 
1

与该行的引用只需填充行变种。

var row = $(this).parent().parent().parent().find('tr#' + id); 
var html = $(row).html(); 
$(row).remove();