HTML DOM Body text 屬性
定義和用法
text 屬性可設置或者返回body 元素的text 屬性值。
text 屬性描述了文檔的文本顏色。
語法
設置text 屬性:
bodyObject.text="color"
返回text 屬性:
bodyObject.text
值 | 描述 |
---|---|
color | 指定了文本颜色。查看完整的 CSS 颜色值 |
瀏覽器支持
所有主要瀏覽器都支持text 屬性。
實例
實例
返回body 元素的text 屬性值:
<html>
<body id="w3s" text="#0000FF">
<script>
document.write("The text color is: ")
document.write(document.getElementById("w3s").text);
</script>
</body>
</html>
<body id="w3s" text="#0000FF">
<script>
document.write("The text color is: ")
document.write(document.getElementById("w3s").text);
</script>
</body>
</html>
嘗試一下»
Body對象