add class in createelement code example
Example 1: create element javascript with class
// create div element by javascript with class
var div = document.createElement('div');
div.className = "div1";
Example 2: javascript add class to element
var someElement= document.getElementById("myElement");
someElement.className += " newclass";//add "newclass" to element (space in front is important)