JavaScript String - sub() Method
Advertisements
Description
This method causes a string to be displayed as a subscript, as if it were in a <sub> tag.
Syntax
Its syntax is as follows −
string.sub( )
Return Value
Returns the string with <sub> tag.
Example
Try the following example.
Live Demo<html> <head> <title>JavaScript String sub() Method</title> </head> <body> <script type = "text/javascript"> var str = new String("Hello world"); alert(str.sub()); </script> </body> </html>
Output
<sub>Hello world</sub>