ltr / rtl is determined by the css "direction" property. It can also be defined using the "dir" attribute for an element in the DOM.
If you are checking the attribute value, use the getAttribute method:
document.getElementById('example').getAttribute('dir');
Also check the style of the item. By default, it is equal to ltr, therefore, if undefined, should be returned as an empty string. Otherwise, he should say: "rtl"
document.getElementById('example').style.direction;
https://developer.mozilla.org/en/CSS/direction
source share