HTML DOM direction 屬性
定義和用法
direction 屬性設(shè)置元素的文本方向。
語法:
Object.style.direction=ltr|rtl|inherit
Possible Values
值 | 描述 |
---|---|
ltr | 默認(rèn)。內(nèi)容從左向右流動。 |
rtl | 內(nèi)容從右向左流動。 |
inherit | 內(nèi)容流動從父元素繼承。 |
實例
本例把文本設(shè)置為從右向左流動:
<html>
<head>
<script type="text/javascript">
function changeTextDirection()
{
document.getElementById("p1").style.direction="rtl";
}
</script>
</head>
<body>
<p id="p1">This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.</p>
<input type="button" onclick="changeTextDirection()"
value="Set text to flow right to left" />
</body>
</html>