javascript - 在 IE8 中无法使用 document.getElementById 找到 DOM

标签 javascript dom internet-explorer-8 getelementbyid

我试图使用 document.getElementById("my_id") 来获取 DOM 的句柄,但无法做到。 我的代码流程有两个阶段: 第一阶段(有效):

document.getElementById("my_text_field").style.visibility = "hidden";

document.getElementById("my_text_field").style.display= "none";

我不知道上面哪一个会被执行。

第 2 阶段(不起作用):

document.getElementById("my_text_field").style.visibility = "visible";

document.getElementById("my_text_field").style.display = "table-row";

这两个阶段在 Firefox 3.6 中都运行良好(我必须使用 3.6)。 但似乎在第 1 阶段,DOM 变得隐藏/不可见,因此 IE8 无法使用 document.getElementById() 找到它们。

请指教。

谢谢。

最佳答案

也许问题是table-row support in IE :

The values "inline-table", "run-in", "table", "table-caption", "table-cell", "table-column", "table-column-group", "table-row", "table-row-group", and "inherit" is not supported in IE7 and earlier. IE8 requires a !DOCTYPE. IE9 supports the values.

关于javascript - 在 IE8 中无法使用 document.getElementById 找到 DOM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8251616/

相关文章:

javascript - IE9 selectSingleNode 在 beta 中丢失,如何在 JavaScript 中克服这个问题?

javascript - 如何从 Web api 捕获具有多个对象的 $scope 对象

javascript - 暂时禁用方形的点击事件监听器(拾色器游戏)

jquery - 如何使用 jQuery 获取特定元素后找到的第一个元素 "further in the DOM"

javascript - ReactDOM.findDOMNode() 使用 React.Children child

twitter-bootstrap - Bootstrap 下拉菜单在 IE8 中不起作用

javascript - XPage、Javascript - 解析 JSON 并返回所有键的值

javascript - 如何在 IE8 中禁用 body.blur()?

winforms - WebBrowser 控件不会显示同一台 PC 上的 IE8 会显示的 https 站点

javascript - 垂直包裹一个div