JQuery:第一个小于X td的tr

时间:2014-10-11 16:05:43

标签: javascript jquery html web frontend

我试图在第一行包含少于3个单元格的表格中插入<td>

这种风格的东西:

var table = $...
table.$(some query that brings the first tr with less than 3 td's).append(myTDvar)

谢谢!

1 个答案:

答案 0 :(得分:6)

尝试这样的事情:

$table.find('tr').filter(function() {
    return this.children.length < 3;
}).eq(0).append(myTDvar);