Core JavaScript 1.5 Reference:Global Objects:String:sub
From MDC
Non-standard
Contents |
[edit] 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, NES2.0 |
[edit] Syntax
sub()
[edit] Parameters
None.
[edit] 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.
[edit] Examples
[edit] 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.