如何使用jquery删除具有给定类名的组tr?
我在一个表中有一个给定的tr组,我需要根据group的类名删除它。我的方式不起作用如何使用jquery删除具有给定类名的组tr?,jquery,Jquery,我在一个表中有一个给定的tr组,我需要根据group的类名删除它。我的方式不起作用 $("table tr").each(function() { $(this).hasClass('group').remove(); }); 应改为: $("table tr").each(function () 在进一步检查时,应将代码 $("table tr").each(function () { if( $(this).hasClass('gro
$("table tr").each(function()
{
$(this).hasClass('group').remove();
});
应改为:
$("table tr").each(function ()
在进一步检查时,应将代码
$("table tr").each(function () {
if( $(this).hasClass('group') )
$(this).remove();
});
你的代码有点小错误
$("table tr").each(function()
{
if($(this).hasClass('group'))
$(this).remove();
});
如果元素集具有在param中指定的类,则返回布尔值true。如果不是,它将返回false。因此,您需要应用条件检查,然后执行操作。请尝试,这应该会起作用
$("tr").each(function()
{
if($(this).hasClass('group'))
$(this).remove();
});
$("tr").each(function()
{
if($(this).hasClass('group'))
$(this).remove();
});