title: HTML DOM alerting style.width
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5525049/get-element-width-in-px">Get element width in px</a>  </p>
  </blockquote>
  
  
  
  <p>How can I find the width of divA? This code brings up an empty alert popup.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  function DisplayResult(){
      width = document.getElementById("divA").style.width;
      alert(width);
  }
  var widthFinder = {   
      find: DisplayResult
  };
  widthFinder.find();
  
  &lt;/script&gt;
  
  &lt;div id="divA"&gt;Alert this string's length in pixels&lt;/div&gt;
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>This now alerts "null". Still not quite what im hoping for.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  
  function DisplayResult(){
  var width = $("#divA").width();
  alert(width);
  }
  var widthFinder = {   
  find: DisplayResult
  };
  widthFinder.find();
  
  &lt;/script&gt;
  
  &lt;div id="divA" style="display:inline; width:100%;"&gt;Alert this string's length in pixels&lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>