title: Javascript - simply get height of an element
body: <p>I know this properbly is a duplicate, but i cant get it right from some of the other answers!
  Really hope you can help!</p>
  
  <p>I simply want to get the width of an element, and then assign it to the height of the same element.</p>
  
  <p>But i cant seem to get the width passed... 
  And I really dont know why - just gets and "undefined".</p>
  
  <p>Read something about the js asking for the width before the elements are added to the DOM, but no matter where I place my "onload", og place the js script, it doesnt seem to make any difference, and i still can add static height to the same element, but just cant get the width! Thanks!</p>
  
  <pre><code>var width_ele = document.getElementsByClassName("image");
  var width = width_ele[0].style.offsetWidth;
  
  alert(width);
  
  var ele = document.getElementsByClassName("image");
  for (var i = 0; i &lt; ele.length; i++) {
  ele[i].style.height = 100 + "px"; // here I wanted the "100" to be the variable "width"...
  }
  </code></pre>
  
  <p><a href="http://jsfiddle.net/qL0hj4jc/10/" rel="nofollow">http://jsfiddle.net/qL0hj4jc/10/</a></p>