텍스트 방향을 설정하려면 방향을 사용하세요. JavaScript로 속성. rtl 설정 오른쪽에서 왼쪽 또는 ltr 왼쪽에서 오른쪽으로 텍스트 방향을 지정합니다.
예시
다음 코드를 실행하여 JavaScript로 텍스트 방향을 설정할 수 있습니다 -
<!DOCTYPE html>
<html>
<body>
<h1 id="myID">Heading 1</h1>
<p>Click below to set the direction of heading to Left-to-right</p>
<button type="button" onclick="display()">Click to change the direction</button>
<script>
function display() {
document.getElementById("myID").style.direction = "rtl";
}
</script>
</body>
</html>