สไตล์ข้อความแปลงคุณสมบัติ
ตัวอย่าง
เปลี่ยนอักษรตัวแรกของแต่ละคำในองค์ประกอบเป็นตัวพิมพ์ใหญ่:
document.getElementById("demo").style.textTransform = "capitalize";
ความหมายและการใช้งาน
คุณสมบัติ textTransform ตั้งค่าหรือส่งคืนการใช้อักษรตัวพิมพ์ใหญ่ของข้อความ
คุณสมบัตินี้ใช้เพื่อเปลี่ยนข้อความเป็นตัวพิมพ์ใหญ่ ตัวพิมพ์เล็ก หรือตัวพิมพ์ใหญ่
รองรับเบราว์เซอร์
Property | |||||
---|---|---|---|---|---|
textTransform | Yes | Yes | Yes | Yes | Yes |
ไวยากรณ์
ส่งคืนคุณสมบัติ textTransform:
object.style.textTransform
ตั้งค่าคุณสมบัติ textTransform:
object.style.textTransform = "none|capitalize|uppercase|lowercase|initial|inherit"
มูลค่าทรัพย์สิน
Value | Description |
---|---|
none | No characters are transformed. This is default |
capitalize | The first character of each word is transformed to uppercase |
uppercase | All characters are transformed to uppercase |
lowercase | All characters are transformed to lowercase |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
รายละเอียดทางเทคนิค
ค่าเริ่มต้น: | ไม่มี |
---|---|
คืนมูลค่า: | สตริงที่แสดงถึงการเปลี่ยนแปลงของข้อความในองค์ประกอบ |
เวอร์ชัน CSS | CSS1 |
ตัวอย่างเพิ่มเติม
ตัวอย่าง
แปลงอักขระทั้งหมดในองค์ประกอบเป็นตัวพิมพ์ใหญ่:
document.getElementById("demo").style.textTransform = "uppercase";
ตัวอย่าง
ส่งคืนการแปลงข้อความขององค์ประกอบ:
alert(document.getElementById("demo").style.textTransform);
หน้าที่เกี่ยวข้อง
กวดวิชา CSS: CSS Text
การอ้างอิง CSS: คุณสมบัติการแปลงข้อความ
❮ สไตล์วัตถุ