How to detect text direction of element using Javascript?
html, javascript, right-to-left
Solution
`getComputedStyle` is available in modern browsers (IE9+ and the others).
getComputedStyle(document.getElementById('foo')).direction
http://jsfiddle.net/m8Zwk/
Reference to getComputedStyle on Mozilla Developer Network
Problem
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". ``` <div dir="ltr" id="foo">bar</div> <div style="direction:ltr" id="baz">quux</div> <div dir="ltr"><div id="jeez">whiz</div></div> ``` How would I test for the direction on "foo", "baz" or "jeez"?