The sup method returns a superscript string defined using the HTML sup tag attribute. The syntax is as follows:
The code copy is as follows:
str_object.sup()
Tip: This method does not comply with ECMA standards and is not recommended for use.
sup method example:
The code copy is as follows:
<script language="JavaScript">
document.write( 'Wulin.com' + 'Every little progress is a solid footprint on our road to success'.sup() );
</script>
Run this example and output:
The code copy is as follows:
Every little progress in Wulin.com is a solid footprint on our road to success
Tip: This method returns a superscript string defined using the HTML sup tag, that is, using this method cannot directly change the string to a superscript style. If you want to dynamically change the element font to the superscript style, you can refer to the following example:
Change the up and down alignment of font text (superscript/subscript)
The code copy is as follows:
<html>
<script language="JavaScript">
function changFont( x ){
document.getElementById("sub_title").style.verticalAlign = x;
}
</script>
<body>
<p>
<a onClick="changFont('sub');">Subscript style</a> <a onClick="changFont('super');">Superscript style</a>
</p>
<p>
Wulin.com<span id="sub_title">Every little progress is a solid footprint on our road to success</span>
</p>
</body>
</html>
In this example, JavaScript controls the text CSS vertical-align style to dynamically change the up and down alignment of font text (superscript/subscript).