sub

Non-standard

Summary

Causes a string to be displayed as a subscript, as if it were in a SUB tag.

Method of String
Implemented in JavaScript 1.0
ECMAScript Edition none

Syntax

sub()

Parameters

None.

Description

Use the sub method with the write or writeln methods to format and display a string in a document. In server-side JavaScript, use the write function to generate the HTML.

Examples

Example: Using sub and sup methods to format a string

The following example uses the sub and sup methods to format a string:

var superText="superscript"
var subText="subscript"

document.write("This is what a " + superText.sup() + " looks like.")
document.write("<P>This is what a " + subText.sub() + " looks like.")

This example produces the same output as the following HTML:

This is what a <SUP>superscript</SUP> looks like.
<P>This is what a <SUB>subscript</SUB> looks like.

See Also

sup


Tags (1)

Edit tags

Attachments (0)

 

Attach file