W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h3>如何访问 BDO 元素的演示</h3> <p><bdo id="myBdo" dir="rtl">这一段将从右到左。</bdo></p> <p>单击按钮可获取 bdo 元素内文本的文本方向。</p> <button onclick="myFunction()">试一试</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>