The sup method returns a superscript string defined using the HTML sup tag attribute. The syntax is as follows:
str_object.sup()
Tip: This method does not comply with ECMA standards and is not recommended.
sup method example:
<script language="JavaScript">
('I' + 'Every little progress is a solid footprint on our road to success'.sup() );
</script>
Run this example and output:
IEvery little progress 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)
<html>
<script language="JavaScript">
function changFont( x ){
("sub_title"). = x;
}
</script>
<body>
<p>
<a onClick="changFont('sub');">Subscript style</a> <a onClick="changFont('super');">Superscript style</a>
</p>
<p>
Every little progress I make 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).