Javascript childelementcount无法在IE 8及更低版本中运行(在其他浏览器中很好) [英] Javascript childelementcount not working in IE 8 and lower(fine in other browsers)

查看:188
本文介绍了Javascript childelementcount无法在IE 8及更低版本中运行(在其他浏览器中很好)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个javascript函数来添加动态文本框,我使用childelementcount来计算添加的智能节点。它适用于IE 8及更低版本以外的所有浏览器。所以我尝试了childNodes.length,它在每个浏览器中给出了不同的限制。我该如何解决这个问题?真的有点帮助家伙。下面是函数。



Hi,
I have a javascript function to add dynamic textboxes and I was using childelementcount to count the chile nodes added. It works fine in every browser other than IE 8 and lower. So I tried childNodes.length which gives me different limit in each browser. How do I solve this? Really appreacite some help guys. Below is the function.

function AddTextBox() {
        if (document.getElementById("TextBoxContainer").childNodes.length < 21) {
            var div = document.createElement('DIV');
            div.innerHTML = GetDynamicTextBox("");
            document.getElementById("TextBoxContainer").appendChild(div);
        }
    }

推荐答案

修正了它。我不得不使用getElementsbytagname并解决了它。
Fixed it. I had to use the getElementsbytagname and that solved it.


这篇关于Javascript childelementcount无法在IE 8及更低版本中运行(在其他浏览器中很好)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆