JavaScript sub()Method

String 对象参考手册JavaScript String Object

Definition and Usage

The sub() method is used to display a string as subscript.

This method returns the string with the <sub> tag added, as shown below:

<sub>string</sub>

Syntax

string.sub()


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the sub() method.


Example

Example

Display a string as subscript:

<script>

var str = "Hello world!";
document.write(str.sub());

</script>

Try it yourself »


String 对象参考手册JavaScript String Object Other Extensions