x
 
<!DOCTYPE html>
<html>
<body>
<p id="demo" style="direction:rtl;">这是示例段落。</p>
<button type="button" onclick="myFunction()">返回文本方向</button>
<script>
function myFunction() {
  alert(document.getElementById("demo").style.direction);
}
</script>
</body>
</html>