IE和Firefox之间的Javascript差异

Yso*_*oL8 2 javascript object-detection

我有以下几行Javascript:

 var button = document.getElementById("scriptsubmit");
 button.setAttribute("class", "remove");
Run Code Online (Sandbox Code Playgroud)

在Firefox中,这非常有效,而在Internet Explorer中却没有.

我知道Internet Explorer期望class是className,但是我不确定如何检测哪个用作对象检测在这种情况下似乎不适用.

谢谢你的回复

Pat*_*Pat 5

您可以直接在两个浏览器中使用className属性:

var button = document.getElementById("scriptsubmit");
button.className = "remove";
Run Code Online (Sandbox Code Playgroud)