要设置文本装饰的颜色,请使用JavaScript中的textDecorationColor 属性。
您可以尝试运行以下代码来更改文本装饰的颜色-
<!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>