Check out example codes for "x.innerHTML += document.body.appendChild(x); x.style.width="100px";". It will help you in understanding the concepts better.

Code Example 1

<!DOCTYPE html>
<html>
<head>

<script type="text/javascript">

var position=0;

function deplacement(){

 position=position+20;
 var mon_element=document.getElementById("element_a_deplacer");

 mon_element.style.marginLeft=position+'px';

 if(position<=300){
  setTimeout(deplacement,50);
 }
}
</script>
</head>
<body>

<div id="element_a_deplacer" style='margin-left:0px;height:30px;width:30px;background:red;'></div>
<br>
<button onclick='deplacement()'>teste</button>
</body>
</html>

Learn ReactJs, React Native from akashmittal.com