Latest web development tutorials
×

JavaScript & HTML DOM คู่มืออ้างอิง

ภาพรวม

JavaScript วัตถุ

JavaScript Array วัตถุ JavaScript Boolean วัตถุ JavaScript Date วัตถุ JavaScript Math วัตถุ JavaScript Number วัตถุ JavaScript String วัตถุ JavaScript RegExp วัตถุ JavaScript อสังหาริมทรัพย์ทั่วโลก / ฟังก์ชั่น JavaScript ผู้ประกอบการ

Browser วัตถุ

Window วัตถุ Navigator วัตถุ Screen วัตถุ History วัตถุ Location วัตถุ

DOM วัตถุ

HTML DOM Document วัตถุ HTML DOM วัตถุธาตุ HTML DOM แอตทริบิวต์วัตถุ HTML DOM วัตถุที่จัดกิจกรรม

HTML วัตถุ

<a> <area> <audio> <base> <blockquote> <body> <button> <canvas> <col> <colgroup> <datalist> <del> <details> <dialog> <embed> <fieldset> <form> <iframe> <frameset > <img> <ins> <input> - button <input> - checkbox <input> - color <input> - date <input> - datetime <input> - datetime-local <input> - email <input> - file <input> - hidden <input> - image <input> - month <input> - number <input> - range <input> - password <input> - radio <input> - reset <input> - search <input> - submit <input> - text <input> - time <input> - url <input> - week <keygen> <link> <label> <legend> <li> <map> <menu> <menuItem> <meta> <meter> <object> <ol> <optgroup> <option> <param> <progress> <q> <script> <select> <source> <style> <table> <td> <th> <tr> <textarea> <title> <time> <track> <video>

DOM HTML เขียน () วิธีการ

อ้างอิงวัตถุเอกสาร วัตถุเอกสาร

ความหมายและการใช้งาน

เขียน () วิธีการในการแสดงออกสามารถเขียน HTML หรือรหัส JavaScript เพื่อให้เอกสาร

ไวยากรณ์

document.write(exp1,exp2,exp3,...)

参数 描述
exp1,exp2,exp3,... 可选。要写入的输出流。多个参数可以列出,他们将按出现的顺序被追加到文档中


สนับสนุนเบราว์เซอร์

Internet ExplorerFirefoxOperaGoogle ChromeSafari

เบราว์เซอร์ที่สำคัญทั้งหมดสนับสนุนการเขียน () วิธีการ


ตัวอย่าง

ตัวอย่างที่ 1

เขียนข้อความบางอย่างเพื่อให้กระแสออกไปนี้:

<html>
<body>

<script>
document.write("Hello World!");
</script>

</body>
</html>

ลอง»

ตัวอย่างที่ 2

เขียนข้อความในรูปแบบสตรีมเอาท์พุท:

<html>
<body>

<script>
document.write("<h1>Hello World!</h1><p>Have a nice day!</p>");
</script>

</body>
</html>

ลอง»

ตัวอย่างที่ 3

เขียน () และ writeln () ความแตกต่าง:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
</head>
<body>

<p>注意write()方法不会在每个语句后面新增一行:</p>

<script>
document.write("Hello World!");
document.write("Have a nice day!");
</script>

<p>注意writeln()方法在每个语句后面新增一行:</p>
<script>
document.writeln("Hello World!");
document.writeln("Have a nice day!");
</script>

</body>
</html>

ลอง»


อ้างอิงวัตถุเอกสาร วัตถุเอกสาร