ป้ายกำกับhtmlสำหรับทรัพย์สิน
ตัวอย่าง
ส่งคืนค่าแอตทริบิวต์ for ของป้ายกำกับ:
var x = document.getElementById("myLabel").htmlFor;
ความหมายและการใช้งาน
ชุดคุณสมบัติ htmlFor หรือคืนค่าของแอตทริบิวต์ for ของป้ายกำกับ
แอตทริบิวต์ for ระบุองค์ประกอบแบบฟอร์มที่ป้ายกำกับถูกผูกไว้
รองรับเบราว์เซอร์
Property | |||||
---|---|---|---|---|---|
htmlFor | Yes | Yes | Yes | Yes | Yes |
ไวยากรณ์
ส่งคืนคุณสมบัติ htmlFor:
labelObject.htmlFor
ตั้งค่าคุณสมบัติ htmlFor:
labelObject.htmlFor = id
มูลค่าทรัพย์สิน
Value | Description |
---|---|
id | The id of the element the label is bound to |
รายละเอียดทางเทคนิค
คืนมูลค่า: | สตริงที่แสดงถึง id ขององค์ประกอบที่ป้ายกำกับถูกผูกไว้กับ |
---|
ตัวอย่างเพิ่มเติม
ตัวอย่าง
เปลี่ยนค่าของแอตทริบิวต์ for ของป้ายกำกับ:
document.getElementById("myLabel").htmlFor = "newValue";
หน้าที่เกี่ยวข้อง
การอ้างอิง HTML: HTML <label> สำหรับแอตทริบิวต์
❮ ป้ายวัตถุ