Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript

วิธีตั้งค่าสีของการตกแต่งข้อความด้วย JavaScript


หากต้องการตั้งค่าสีของการตกแต่งข้อความ ให้ใช้คุณสมบัติ 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>