【发布时间】:2014-08-18 19:29:41
【问题描述】:
我有一些表格,我只需要在这个表格中保留一些内容,所以我有这个
$(truc).find('tr').each(function(lig) {
if (lig != 0 && (!$(this).children(':first').not('')) && (!$(this).children(':first').hasClass('main-title')) && (!$(this).children(':first').hasClass('top-top-title'))) {
$(this).remove();
}
;
}
我需要(!$(this).children(':first').not('')) 的帮助,因为我需要选择第一个孩子没有班级(甚至没有空班)的行并且我不知道我需要哪些指令
编辑:我解决了自己检查$(this).children(':first')是否有属性类的问题
$(this).children(':first').attr('class'),所以如果一个元素没有类,它就不会进入if
【问题讨论】:
-
这是我的变量,里面有表格
-
脏流已经给出了你的问题的答案..
-
您可以获取类属性并将其与''进行比较。只需遍历孩子。
-
我已经看到了这个问题,但是我不知道如何使用答案,或者它们不起作用,我尝试了 $(this).children(':first').not( '班级'); $(this).children(':first').not('[class]'); $(this).children(':first').not([class]),同样的结果