title: How to detect text direction of element using Javascript?
body: <p>What's the best way to detect the text direction of an html element using Javascript?  I would expect to get either "rtl" or "ltr".</p>
  
  <pre><code>&lt;div dir="ltr" id="foo"&gt;bar&lt;/div&gt;
  
  &lt;div style="direction:ltr" id="baz"&gt;quux&lt;/div&gt;
  
  &lt;div dir="ltr"&gt;&lt;div id="jeez"&gt;whiz&lt;/div&gt;&lt;/div&gt;
  </code></pre>
  
  <p>How would I test for the direction on "foo", "baz" or "jeez"?</p>