Set the Type of Line in 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: 2020-06-23T11:26:01+05:30

144 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements