Introduction to JavaScript Sup method (display string as superscript) _ Basics

Source: Internet
Author: User

The SUP method returns the superscript string defined using the HTML SUP Tag property. The syntax is as follows:

Copy Code code as follows:

Str_object.sup ()

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).

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.