The Bdo object represents an HTML <bdo> element.
We can access a <bdo> element by using document.getElementById()
:
var x = document.getElementById("myBdo");
Click the button to get the text direction of the text inside the bdo element.
<!DOCTYPE html> <html> <body> <p><bdo id="myBdo" dir="rtl">This paragraph will go right-to-left.</bdo></p> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from www . ja v a 2 s . com 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>