HTML DOM Body Object
วัตถุในร่างกาย
วัตถุร่างกายแสดงถึงองค์ประกอบ HTML <body>
เข้าถึงวัตถุร่างกาย
คุณสามารถเข้าถึงองค์ประกอบ <body> โดยใช้ getElementsByTagName():
ตัวอย่าง
var x = document.getElementsByTagName("BODY")[0];
เคล็ดลับ:คุณยังสามารถเข้าถึงองค์ประกอบ <body> ได้โดยใช้ คุณสมบัติdocument.body
สร้างวัตถุในร่างกาย
คุณสามารถสร้าง <body> องค์ประกอบโดยใช้ document.createElement() วิธีการ:
var x = document.createElement("BODY");
คุณสมบัติของวัตถุร่างกาย
Property | Description |
---|---|
aLink | Not supported in HTML5. See CSS :active Selector instead.
Sets or returns the color of an active link in a document |
background | Not supported in HTML5. Use style.backgroundImage instead. Sets or returns the background image for a document |
bgColor | Not supported in HTML5. Use style.backgroundColor instead. Sets or returns the background color of a document |
link | Not supported in HTML5. See CSS :link Selector instead. Sets or returns the color of unvisited links in a document |
text | Not supported in HTML5. Use style.color instead. Sets or returns the color of the text in a document |
vLink | Not supported in HTML5. See CSS :visited Selector instead.
Sets or returns the color of visited links in a document |
คุณสมบัติและเหตุการณ์มาตรฐาน
ออบเจ็กต์ Body ยังสนับสนุนคุณสมบัติและเหตุการณ์ มาตรฐาน อีกด้วย
หน้าที่เกี่ยวข้อง
การอ้างอิง HTML: แท็ก HTML <body>