title: Get the width of a div that was created in javascript using createElement
body: <p>I'm using the javascript function createElement to create a div and then setting it's innerHTML.  After that is done I want to get the value for the width required to display the div with its full content.</p>
  <pre><code>var newDiv = document.createElement(&quot;div&quot;);
  
  newDiv.innerHTML = &quot;My new&lt;br/&gt;DIV&quot;;
  
  // Get the width of the div here
  </code></pre>
  <p>I've tried the following:</p>
  <pre><code>Call                                      Result
  --------------------------------------    -------------
  newDiv.width                              undefined
  newDiv.scrollWidth                        0
  newDiv.clientWidth                        0
  newDiv.offsetWidth                        0
  newDiv.innerWidth                         undefined
  newDiv.outerWidth                         undefined
  newDiv.getBoundingClientRect().width      0
  </code></pre>
  <p>The javascript code to create the div is executed on an AJAX callback; I don't know if that has anything to do with the issue or not.</p>