我需要让我的应用程序在所有浏览器上运行,我有一个 div,我使用语法在 Javascript 中设置 css 类
divNew.className = "highlightItem";
它在 IE 上运行良好,但在 Firefox、Opera 和 Chrome 上它根本无法运行。我也尝试过其他版本,例如
var theDiv = document.getElementById(divNew);
theDiv.setAttribute("class", "highlightItem");
theDiv.setAttribute("className", "highlightItem");
没有成功。通过样式设置所有属性也不起作用。
是否有任何其他方法可以为 div 设置 css 类以便它在上述浏览器上工作?非常感谢!