【问题标题】:.rows.length, doesn't work in firefox.rows.length,在 Firefox 中不起作用
【发布时间】:2010-01-20 20:48:04
【问题描述】:

我的 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 is not a function ... etc”

谢谢!!!

【问题讨论】:

    标签: javascript row


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 2016-08-22
      • 2012-11-27
      • 2012-02-27
      • 2017-02-08
      • 2014-08-23
      • 2013-07-12
      • 2016-06-13
      • 2017-08-19
      • 2015-03-16
      相关资源
      最近更新 更多