ประเภทปุ่มคุณสมบัติ
ตัวอย่าง
กลับประเภทของปุ่ม:
var x = document.getElementById("myBtn").type;
ความหมายและการใช้งาน
คุณสมบัติประเภทชุดหรือส่งคืนชนิดของปุ่ม
เคล็ดลับ:ระบุแอตทริบิวต์ type สำหรับปุ่มเสมอ ประเภทเริ่มต้นสำหรับ Internet Explorer คือ "ปุ่ม" ในขณะที่ในเบราว์เซอร์อื่น (และในข้อกำหนด W3C) จะเป็น "ส่ง"
รองรับเบราว์เซอร์
Property | |||||
---|---|---|---|---|---|
type | Yes | Yes | Yes | Yes | Yes |
ไวยากรณ์
ส่งคืนคุณสมบัติประเภท:
buttonObject.type
ตั้งค่าคุณสมบัติประเภท:
buttonObject.type = "submit|button|reset"
มูลค่าทรัพย์สิน
Value | Description |
---|---|
submit | The button is a submit button (this is default for all browsers, except Internet Explorer) |
button | The button is a clickable button (this is default for Internet Explorer) |
reset | The button is a reset button (clears form data) |
รายละเอียดทางเทคนิค
คืนมูลค่า: | สตริงที่แสดงถึงประเภทปุ่ม |
---|
ตัวอย่างเพิ่มเติม
ตัวอย่าง
เปลี่ยนประเภทของปุ่มเป็น "ส่ง":
document.getElementById("myBtn").type = "submit";
ตัวอย่าง
เปลี่ยนประเภทของปุ่มเป็น "รีเซ็ต":
document.getElementById("myBtn").type = "reset";
หน้าที่เกี่ยวข้อง
อ้างอิง HTML: HTML <button> ประเภทแอตทริบิวต์
❮ ปุ่มวัตถุ