Couldn't find here at Stackoverflow.
How can I add additional attribute to an element?
I need this
<div id="test"></div>
to be
<div id="test test2"></div>
document.getElementById("test").setAttribute("id", "test2")
sets to
<div id="test2"></div>
EDIT: the question provided was different question and not about class.