The SUP method returns the superscript string defined using the HTML SUP 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.
Sup Method Instance:
Copy Code code as follows:
<script language= "JavaScript" >
document.write (' cloud-dwelling community ' + ' every bit of progress is a solid footprint on our path to Success '. SUP ());
</script>
Run the example and output:
Copy Code code as follows:
Every bit of progress in the cloud-dwelling community
is a solid footprint on our path to success.
Tip: This method returns the superscript string defined using the HTML SUP tag, which means that the string cannot be changed directly to the superscript style. If you want to dynamically change the element font to superscript style, refer to the following example:
Change font text up/down alignment (superscript/subscript)
Copy Code code as follows:
<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>
Cloud-dwelling community <span id= "Sub_title" > every bit of progress is our solid footprint on the road to success </span>
</p>
</body>
In this example, JavaScript controls the way text CSS vertical-align style to dynamically change the upper and lower alignment of font text (superscript/subscript).