How to set the type of line in a text-decoration with JavaScript?


To set the type of line in text-decoration, use the textDecorationLine property. You can try to run the following code to return the type of line in a text-decoration with JavaScript −

Example

<!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>

Updated on: 23-Jun-2020

84 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements