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