JavaScript strike method entry instance (add a delete line to a string)

  • 2020-03-30 04:08:53
  • OfStack

JavaScript strike method

The strike method returns a string of deletes defined using the HTML strike tag attribute. The syntax is as follows:


str_object.strike()

Note: this method does not conform to ECMA standards and is not recommended.

Instance of strike method


<script language="JavaScript"> var str = "www.jb51.net";
document.write( str.strike( "//www.jb51.net" ) ); </script>

Run the example and output:


www.jb51.net

Tip: this method returns a deletes string defined using the HTML strike tag, that is, it does not directly change a string to a string with deletes. If you want to dynamically change the element font to a string with deletes, see the following example:

Add a decorative effect to the font text (strikeout, underlining, overlining, flashing)


<html>
<script language="JavaScript">
function changFont( x ){
    document.getElementById("article").style.textDecoration = x;
}
</script>
<body>
<p>
<a onClick="changFont('none');"> There is no decoration </a> <a onClick="changFont('line-through');"> Delete the line </a>
<a onClick="changFont('underline');"> The underline </a> <a onClick="changFont('overline');"> On the line </a>
</p>
<p id="article">
I am some words ...<br />
Some Text ...
</p>
</body>
</html>


Related articles: