ในการตั้งค่าประเภทของเส้นในการตกแต่งข้อความ ให้ใช้ 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>