开发者

IE6 not letting JS set attribute

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";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜