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

JavascriptObject Oriented ProgrammingFront End Technology

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>
raja
Published on 27-Feb-2018 07:44:14
Advertisements