HTML DOM dirProperty

元素对象参考手册Element Object


Definition and Usage

The dir property sets or returns the text direction of an element.

Syntax

HTMLElementObject.dir=text-direction


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the dir property


Example

Example

Return the text direction of the body element:

<html>
<body id="myid" dir="rtl">

<script>
var 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>

Try it yourself »


元素对象参考手册Element Object

Other Extensions