.rows.length,在firefox中不起作用

时间:2010-01-20 20:48:04

标签: javascript row

我遇到JavaScript代码问题,它在IE7 / 8中运行,但在Firefox中不起作用

for (var i = 1; i < document.getElementById(obj).rows.length; i++)
{
    var numColumns = document.getElementById(obj).rows(i).cells.length;
    if (numColumns > 0)
    {
        if (document.getElementById(obj).rows(i).cells(numColumns - 1).children.length > 1)
        {
            if (document.getElementById(obj).rows(i).cells(numColumns - 1).children(1).checked == true)
            {
                var ctrlId = document.getElementById(obj).rows(i).cells(numColumns - 1).children(1).id.replace('chk', 'txt')
                workflowIds = workflowIds + (workflowIds == '' ? '' : '|') + document.getElementById(ctrlId).value;
            }
        }
    }
}

错误:“错误:document.getElementById(obj).rows不是函数......等”

谢谢!!!

1 个答案:

答案 0 :(得分:5)

对行和单元格使用[],而不是()(它们是数组!)

document.getElementById(obj).rows[i].cells[numColumns - 1] //...

编辑:children的内容相同。并且更喜欢childNodes,我不知道FF是否理解children