How to create a strikethrough text using JavaScript?


To create a strikethrough text with JavaScript, use the strike() method. This method causes a string to be displayed as struck-out text as if it were in a <strike> tag.

Example

You can try to run the following code to create a strikethrough text −

Live Demo

<html>
   <head>
      <title>JavaScript String strike() Method</title>
   </head>

   <body>
      <script>
         var str = new String("Demo Text");
         document.write(str.strike());
         alert(str.strike());
      </script>
   </body>
</html>

Updated on: 15-Jun-2020

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements