Search code examples
javascripttextbidirectional

JavaScript dir method returns empty string for text direction


This returns an empty string when I try to determine the default text direction...

alert(document.getElementById('example').dir);

I would like to determine if the default text direction is ltr or rtl.


Solution

  • I alert during debugging, like so:

    alert(window.getComputedStyle(document.getElementById('editor_rich')).direction);