How to set the color of the text-decoration with JavaScript?

JavascriptObject Oriented ProgrammingFront End Technology

To set the color of the text-decoration, use the textDecorationColor property in JavaScript.

Example

You can try to run the following code to change the color of the text-decoration −

<!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>
raja
Published on 27-Feb-2018 07:39:16
Advertisements