document.getElementById("gD" + gDay + gMonth + gYear).setAttribute("class", "gDay gDayHover");
This works fine in all modern browsers, unfortunately for me it needs to work in older versions. I'm using IE8's compatibil开发者_StackOverflowity mode, and it doesn't seem to cope with this piece of code.
It's getting the element fine, but not changing it's class. Any ideas?
You might want to have a look at the className
property. This should work fine in IE6 and above.
var elem = document.getElementById("gD" + gDay + gMonth + gYear);
elem.className = "gDay gDayHover";
精彩评论