What happens on IE, our favorite browser, when you try to setup a class attribute on a DOM element? Actually this is not possible, because setAttribute(‘class’, ‘my-class’) is obviously working only on non-IE browsers.

On IE actually you should setup the class on an element with that structure:

element.setAttribute('className', 'my-class');

Related posts:

  1. CSS Priority: The Difference Between a.my-class and .my-class
  2. cssText and how it can be very very useful
  3. JavaScript disable mouse wheel