gpt4 book ai didi

javascript - 浏览器兼容性错误

转载 作者:行者123 更新时间:2023-12-02 20:26:43 24 4
gpt4 key购买 nike

我使用 html 和 js 创建一个网页(在表格中显示详细信息)。它适用于 Firefox,但不适用于 IE。

function frontEnd() 
{
try{
th1 = document.getElementById('th1');
th1.firstChild.nodeValue = "Technology";

th2 = document.getElementById('th2');
th2.firstChild.nodeValue = "Level of knowledge";

t1 = document.getElementById('t1');
t1.firstChild.nodeValue = "HTML";

tl1 = document.getElementById('tl1');
tl1.firstChild.nodeValue = "5";

document.getElementById('MyTab').style.visibility="visible";
}
catch(e)
{
alert(e);
}
}

th1是表头id,t1,tl1是数据id。实际上我试图在用户单击按钮时在表中显示静态值。它在 Firefox 中运行成功,但在 IE 中则不行。使用 IE 单击按钮时,会反射(reflect)错误“[对象错误]”请告诉我如何使相同的代码在 IE 中工作。

谢谢,纳文

最佳答案

为什么不使用JQuery 或 Prototype JavaScript 库,它们是跨浏览器兼容的。

Jquery

http://api.jquery.com/first-child-selector/

关于javascript - 浏览器兼容性错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4733969/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com