JavaScript italics method
The italics method returns a (italics) string defined using the HTML i tag attribute. The syntax is as follows:
The code copy is as follows:
str_object.italics()
Tip: This method does not comply with ECMA standards and is not recommended for use.
Italics method example
The code copy is as follows:
<script language="JavaScript">
var str = "www.VeVB.COM";
document.write( str.italics() );
</script>
Run this example and output:
The code copy is as follows:
www.VeVB.COM
Tip: This method returns a string defined using HTML i tags, that is, using this method, the font cannot be changed dynamically to italics. If you want to dynamically change the element font to italics, you can refer to the following example:
Further reading: Change the font of the page element to italics
The code copy is as follows:
<html>
<script language="JavaScript">
function changFont( x ){
document.getElementById("article").style.fontStyle = x;
}
</script>
<body>
<p>
<a onClick="changFont('normal');">Normal</a> <a onClick="changFont('italic');">Italic</a>
</p>
<p id="article">
I'm some text...<br />
Some Text ...
</p>
</body>
</html>
In this example, the font CSS font-style style can be dynamically changed (id="article") to italics through JavaScript.