HTML DOM dir 属性
定义和用法
dir 属性设置或返回元素的文字方向。
语法:
- object.dir=text-direction
实例
本例展示了两种获取 <body> 元素的文本方向的方法:
- <html>
- <body id="myid" dir="rtl">
- <script type="text/javascript">
- x=document.getElementsByTagName('body')[0];
- document.write("Text direction: " +
x.dir
);- document.write("<br />");
- document.write("An alternate way: ");
- document.write(
document.getElementById('myid').dir
);- </script>
- </body>
- </html>