JavaScript String – sub() 方法 介绍 此方法将字符串显示为下标,就像它在<sub>标签中一样。 语法 语法如下− string.sub( )HTMLCopy 返回值 返回带<sub>标签的字符串。 示例 尝试以下示例。 <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> HTMLCopy 输出 <sub>Hello world</sub> HTMLCopy