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

JavascriptObject Oriented ProgrammingFront End Technology

To set the style of the line in JavaScript, use the textDecorationStyle property. You can set underline, double, or overline, etc for the line style.

Example

You can try to run the following code to return the style of the line in a text-decoration with JavaScript −

<!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.textDecorationStyle = "double";
         }
      </script>
   </body>
</html>
raja
Published on 27-Feb-2018 12:21:59
Advertisements