HTML DOM dir 属性

定義と使用方法

dir 属性は、要素のテキスト方向を設定または返します。

構文:

object.dir=text-direction

この例では、<body> 要素のテキスト方向を取得する2つの方法を示しています:

<html>
<body id="myid" dir="rtl">
<script type="text/javascript">
x=document.getElementsByTagName('body')[0];
document.write("テキスト方向: "); x.dir);
document.write("<br />");
document.write("別の方法: ");
document.write(document.getElementById('myid').dir);
</script>
</body>
</html>