Search code examples
javascriptobject-detection

Javascript difference between IE and Firefox


I have the following lines of Javascript:

 var button = document.getElementById("scriptsubmit");
 button.setAttribute("class", "remove");

In Firefox this works perfectly and in Internet explorer it doesn't.

I am aware that Internet Explorer expects class to be className, but I'm uncertain how to detect which to use as object detection doesn't appear to apply in this case.

Thanks for your replies


Solution

  • You can just use the className property directly in both browsers:

    var button = document.getElementById("scriptsubmit");
    button.className = "remove";