Thuộc tính dir của HTML DOM

Định nghĩa và cách sử dụng

Thuộc tính dir thiết lập hoặc trả về hướng văn bản của phần tử.

Cú pháp:

object.dir=text-direction

Ví dụ

Ví dụ này trình bày hai cách để lấy hướng văn bản của phần tử <body>:

<html>
<body id="myid" dir="rtl">
<script type="text/javascript">
x=document.getElementsByTagName('body')[0];
document.write("Hướng văn bản: "); x.dir);
document.write("<br />");
document.write("Một cách khác: ");
document.write(document.getElementById('myid').dir);
</script>
</body>
</html>