The dir property

The dir property returns a string value that represents the reading direction of the document. This value can be ltr (left to right) or rtl (right to left).
This property is very useful for displaying pages written in languages that are read from right to left.


<input type="button" value="Change It" id="changer" onclick="switch_sides();" />

<script type="text/javascript">
var MyButton = document.getElementById("changer");
MyButton.onclick = function() {
	document.dir = (document.dir!="ltr") ? "ltr" : "rtl";


Leave a Reply