How to set the decoration of a text with JavaScript?

JavascriptObject Oriented ProgrammingFront End Technology

Use the textDecoration property in JavaScript to decorate the text. You can underline a text using this property.

Example

You can try to run the following code to set the decoration of a text with JavaScript −

<!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";
         }
      </script>
   </body>
</html>
raja
Published on 27-Feb-2018 07:34:26
Advertisements