document.getElementById("div_name").setAttribute("class", "class_name");
Generally, it works across different browser nowadays. Unfortunately, some users still using IE7 or even older-version, and we have to take care of them. Here is a JS function for workaround.
function rollStyle (styleObj, styleName) {
if (styleObj.className) {
styleObj.className = styleName;
} else {
document.getElementById(styleObj).className = styleName;
}
}
Usage:
rollStyle("div_name","class_name")