本文介绍了document.getElementById在IE11中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 大家好, 我有一个ASP.NET Datagrid,我正在使用javascript for循环,如下所示。 for (i = 0 ; i< len; i ++){ var inputelements = dgGridname.rows [i] .cells [ 1 ]。getElementsByTagName(' 输入); var max = inputelements.length; if (max> 0 ){ document .getElementById(inputelements [ 0 ]。name).value = document .getElementById(inputelements [ 1 ]。name).value } } 当我在IE8中运行此工作正常但在IE11中我正在获得 document .getElementById(inputelements [ 0 ]。name)为null或undefined。我不知道如何解决IE11的问题。任何人都可以帮忙。解决方案 编辑:实际上,您根本不需要调用 getElementById - 您已经拥有该元素 inputelements 数组: var inputelements = dgGridname .rows [i] .cells [ 1 ]。getElementsByTagName(' 输入); if (inputelements.length> 1 ){ inputelements [ 0 ]。value = inputelements [ 1 ]。value; } Hi All,I have a ASP.NET Datagrid and I am using javascript for loop like below.for (i = 0; i < len; i++) { var inputelements = dgGridname.rows[i].cells[1].getElementsByTagName('input'); var max = inputelements.length; if (max > 0) { document.getElementById(inputelements[0].name).value= document.getElementById(inputelements[1].name).value } }when I run this in IE8 working fine but where as in IE11 I am gettingdocument.getElementById(inputelements[0].name) as null or undefined. I am not sure how to fix this for IE11. can anyone please help. 解决方案EDIT: Actually, you don't need to call getElementById at all - you already have the element in the inputelements array:var inputelements = dgGridname.rows[i].cells[1].getElementsByTagName('input');if (inputelements.length > 1) { inputelements[0].value = inputelements[1].value;} 这篇关于document.getElementById在IE11中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-05 13:10