TUTORIAL前端与浏览器FETCHED
Body text 属性
Body text 属性 Body 对象 定义和用法 text 属性可设置或者返回 body 元素的 text 属性值。 text 属性描述了文档的文本颜色。 语法 设置 text 属性: bodyObject.text='color' 返回 text 属性: bodyObject.text 值 描述 color 指定了文本颜色。查看完整的 CSS 颜色值 ..
更新于 2026/7/16
教程详情页默认 noindex。
Body text 属性
Body 对象
定义和用法
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 对象