This article mainly introduces the introductory examples of the JavaScript italics method. The italics method is used to display strings in italics. Friends in need can refer to
JavaScript italics method
Theitalics method returns a (italicized) string defined using the HTML i tag attribute. The syntax is as follows:
str_object.italics()
Tip: This method does not comply with ECMA standards and is not recommended.
italics method instance
<script language="JavaScript"> var str = "m.sbmmt.com"; document.write( str.italics() ); </script>
Run this example, output:
m.sbmmt.com
Tip: This method returns a string defined using the HTML i tag, even if you use this method, you cannot dynamically change the font to italic. If you want to dynamically change the element font to italic, you can refer to the following example:
Further reading: Change the page element font to italic
<html> <script language="JavaScript"> function changFont( x ){ document.getElementById("article").style.fontStyle = x; } </script> <body> <p> <a onClick="changFont('normal');">正常</a> <a onClick="changFont('italic');">斜体</a> </p> <p id="article"> 我是一些文字 ...<br /> Some Text ... </p> </body> </html>
In this example, By controlling the font CSS font-style style through JavaScript, the font (id="article") can be dynamically changed to italic.
The above is the entire content of this chapter. For more related tutorials, please visit JavaScript Video Tutorial!