HTML DOM dir Property
Definition and Usage
The dir property sets or returns the text-direction for an element.
Syntax
object.dir=text-direction
|
Example
The following example shows two methods on how to get the text direction for the <body>
element:
<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>
|
Output:
Text direction: rtl
An alternate way: rtl
|
Try-It-Yourself Demos
Return the
text direction for the <body> element
|