JavaScript Italics method
The Italics method returns the (italic) string defined using the HTML I tag property. The syntax is as follows:
Copy Code code as follows:
Tip: This method does not conform to the ECMA standard and is not recommended for use.
Italics Method Instance
Copy Code code as follows:
<script language= "JavaScript" >
var str = "Www.jb51.net";
document.write (Str.italics ());
</script>
Run the example and output:
Copy Code code as follows:
Tip: This method returns the string defined using the HTML I tag, that is, using this method does not dynamically change the font to italic. If you want to dynamically change the element font to italic, refer to the following example:
Extended reading: Changing page element font to italic
Copy Code code as follows:
<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 am some words ... <br/>
Some Text ...
</p>
</body>
In this example, you can dynamically change the font (id= "article") to italic by using JavaScript to control the way the font CSS font-style style.