atribut teks HTML DOM Tubuh
Definisi dan Penggunaan
teks set properti atau mengembalikan atribut teks elemen body.
atribut teks menggambarkan warna teks dokumen.
tatabahasa
Mengatur atribut teks:
bodyObject.text="color"
Pengembalian atribut teks:
bodyObject.text
值 | 描述 |
---|---|
color | 指定了文本颜色。查看完整的 CSS 颜色值 |
Dukungan Browser
Semua browser utama mendukung atribut teks.
contoh
contoh
Mengembalikan elemen teks nilai atribut tubuh:
<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>
Coba »
tubuh Object