หากต้องการตั้งค่าประเภทของเส้นในการตกแต่งข้อความ ให้ใช้คุณสมบัติ textDecorationLine คุณสามารถลองรันโค้ดต่อไปนี้เพื่อคืนค่าประเภทของเส้นในการตกแต่งข้อความด้วย JavaScript −
ตัวอย่าง
<!DOCTYPE html> <html> <body> <div id = "myText" style = "text-decoration: underline;"> This is demo text. </div> <br> <button onclick="display()"> Set Text Decoration </button> <script> function display() { document.getElementById("myText").style.textDecorationColor = "red"; document.getElementById("myText").style.textDecorationLine = "overline"; } </script> </body> </html>