Between both those :
function setCss(object, css) { return (object.className = css); } function getCss(object, css) { return ob
getAttribute("class") is more universal, because it can be used in different types of documents. In XML documents, most importantly. Including SVG.
getAttribute("class")
element.className works only in HTML. It is described in the DOM level 2 HTML specs.
element.className