1// create div element by javascript with class
2
3var div = document.createElement('div');
4div.className = "div1";
5
1Let suppose we are creating a div using javascript create element
2// create a new div element
3 var newDiv = document.createElement("div");
4// assigning class name to the new div
5 newDiv.className = "className";
1var element =document.createElement("span");
2 element.className = "aClassName";