Example of getting started with JavaScript sup method (displaying strings as superscripts), javascriptsup

Source: Internet
Author: User
Tags string methods

Example of getting started with JavaScript sup method (displaying strings as superscripts), javascriptsup

The sup method returns the supermark string defined using the HTML sup tag attribute. The syntax is as follows:

Copy codeThe Code is as follows:
Str_object.sup ()

Tip: This method does not comply with the ECMA standard and is not recommended.

Sup method example:

Copy codeThe Code is as follows:
<Script language = "JavaScript">
Document. write ('helping home' + 'Every progress is a solid footprint on our road to success'. sup ());
</Script>

Run this example and output:

Copy codeThe Code is as follows:
Every progress made by the customer's house is a solid footprint on the road to success.

Tip: This method returns the supermark string defined using the HTML sup tag. That is, the string cannot be changed to the supermark style directly by using this method. If you want to dynamically change the element font to an upper style, refer to the following example:

Change the font text upper/lower alignment mode (superscript/subscript)

Copy codeThe Code 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>
<Span id = "sub_title"> every progress is a solid footprint on the road to success </span>
</P>
</Body>
</Html>

In this example, JavaScript controls the text CSS vertical-align style to dynamically change the upper and lower alignment of the font text (superscript/subscript ).


Javascript Problems

There are too many string methods. What do you need?
String object Method
FF: Firefox, N: Netscape, IE: Internet Explorer

Method description FF N IE
Anchor () creates an HTML anchor. 1 2 3
Big () displays strings in a large font. 1 2 3
Blink () displays the flashing string. 1 2
Bold () displays strings in bold. 1 2 3
CharAt () returns the character at the specified position. 1 2 3
CharCodeAt () returns the Unicode encoding of characters at the specified position. 1 4 4
Concat () connection string. 1 4 4
Fixed () displays strings in typewriter text. 1 2 3
Fontcolor () uses the specified color to display strings. 1 2 3
Fontsize () uses the specified size to display the string. 1 2 3
FromCharCode () creates a string from the character encoding. 1 4 4
IndexOf () to retrieve strings. 1 2 3
Italics () uses italics to display strings. 1 2 3
LastIndexOf () searches for strings from the back and forward. 1 2 3
Link () displays the string as a link. 1 2 3
LocaleCompare () compares two strings in a specific local order. 1 4 4
Match () finds the matching of one or more in-process expressions. 1 4 4
Replace () replaces the substring that matches the regular expression. 1 4 4
Search () searches for values that match regular expressions. 1 4 4
Slice () extracts the string segment and returns the extracted part in the new string. 1 4 4
Small () uses a small font size to display strings. 1 2 3
Split () splits the string into a string array. 1 4 4
Strike () uses strikethrough to display strings. 1 2 3
Sub () displays the string as a subscript. 1 2 3
Substr () extracts a specified number of characters from the start index number. 1 4 4
Substring () is used to extract the characters between two specified index numbers. 1 2 3
Sup () displays the string as a superscript. 1 2 3
ToLocaleLowerCase () converts the string to lowercase. ---
ToLocaleUpperCase () converts the string to uppercase. ---
ToLowerCase () converts a string to lowercase. 1 2 3
ToUpperCase () converts a string to uppercase. 1 2 3
ToSource () indicates the source code of the object. 1 4-
ToString () returns a string. ---
ValueOf () returns the original value of a string object. 1 2 4

In PHPExcel, how do I set the superscript and subscript? <Sub> and <sup>

I am also looking for this. For now, I only find the cell superscript and subscript setting attributes: setSuperScript () and setSubScript (). I have not found how to set some text.

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.