Edit This Code:
<!DOCTYPE html>
<html>
<body>

<h3>A demonstration of how to access a BDO element</h3>

<p><bdo id="myBdo" dir="rtl">This paragraph will go right-to-left.</bdo></p>  

<p>Click the button to get the text direction of the text inside the bdo element.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("myBdo");
    if (x.dir === "rtl") {
        document.getElementById("demo").innerHTML = "Text direction is right to left.";
    } else {
        document.getElementById("demo").innerHTML = "Text direction is left to right.";
    }
}
</script>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy