2012-01-16 49 views
2

我正在tryng得到所有从其中跨度属性没有被定义获取所有不具有跨度属性

$('tr').each(function() { 
    $(this).find('td').each(function() { 
    if (($(this).text().trim() == "")) && // and this td not has colspan attribute { 
     $(this).closest("td").remove(); 
     }; 
    }); 
}); 
+2

可能重复[我怎样才能得到元素,而无需通过jQuery的特定属性(http://stackoverflow.com/questions/1073779/how-can-i -get-the-elements-without-a-specific-attribute-by-jquery) – 2012-01-16 10:42:48

+0

你想要移除相同的td或prev td吗? – 2012-01-16 10:50:07

+0

我需要删除相同的TDD – maaz 2012-01-16 10:52:11

回答

2

按OP的评论,他希望与no colspan和删除td 10值。我想这可以在一行中完成。试试这个

$('td:empty:not([colspan])').remove(); 

小提琴:http://jsfiddle.net/F92De/1/

0
$('tr').each(function() { 
    $(this).find('td').each(function() { 
    if (($(this).text().trim() == "")) && !$(this).attr('colspan') { 
     $(this).closest("td").remove(); 
     }; 
    }); 
}); 
0
$('tr').each(function() { 
    $(this).find('td:not([colspan])').each(function() { 
    if (($(this).text().trim() == "")) { 
     $(this).closest("td").remove(); 
     }; 
    }); 
}); 
0

每一行的TD的TD你发现了多少TD在

$.each($('.tbody tr'), function() { 
    var td1 = $(this).find('td'); 
    if(td1.length >= 2) { 
     var orders = td1.eq(1).html().trim(); 

    } 
});