You can do like this, swap the elements order in the parent node.
var div1 = document.getElementsByClassName("div1")[0];
var div2 = document.getElementsByClassName("div2")[0];
div2.parentNode.insertBefore(div2, div1);
0
solved Can i change HTML structure with javascript? [closed]