JavaScript Sub Method
The Sub method returns the subscript string defined using the HTML Sub Label 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.
Sub 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 '. Sub ());
</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 subscript string defined by using an HTML sub tag, which means that the string cannot be changed directly to the subscript style. If you want to dynamically change the element font to subscript 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).