วัตถุที่ซ่อนการป้อนข้อมูล HTML DOM
ใส่วัตถุที่ซ่อนอยู่
วัตถุอินพุตที่ซ่อนอยู่แสดงถึงองค์ประกอบ HTML <input> ที่มีประเภท="ซ่อน"
เข้าถึงวัตถุที่ซ่อนอยู่อินพุต
คุณสามารถเข้าถึง <input> องค์ประกอบด้วย type="hidden" โดยใช้ getElementById():
ตัวอย่าง
var x = document.getElementById("myInput");
เคล็ดลับ:คุณยังสามารถเข้าถึง <input type="hidden"> โดยการค้นหาผ่าน คอลเลคชัน องค์ประกอบของฟอร์ม
สร้างอินพุตวัตถุที่ซ่อนอยู่
คุณสามารถสร้าง <input> องค์ประกอบด้วย type="hidden" โดยใช้ document.createElement() วิธีการ:
ตัวอย่าง
var x = document.createElement("INPUT");
x.setAttribute("type", "hidden");
ป้อนคุณสมบัติของวัตถุที่ซ่อนอยู่
Property | Description |
---|---|
defaultValue | Sets or returns the default value of the hidden input field |
form | Returns a reference to the form that contains the hidden input field |
name | Sets or returns the value of the name attribute of the hidden input field |
type | Returns which type of form element a hidden input field is |
value | Sets or returns the value of the value attribute of the hidden input field |
คุณสมบัติและเหตุการณ์มาตรฐาน
ออบเจ็กต์ที่ซ่อนอินพุตยังสนับสนุนคุณสมบัติและเหตุการณ์ มาตรฐาน อีกด้วย
หน้าที่เกี่ยวข้อง
กวดวิชา HTML: แบบฟอร์ม HTML
อ้างอิง HTML: HTML <input> tag
อ้างอิง HTML: HTML <input> ประเภทแอตทริบิวต์