Javascript examples for String:sub
The sub() method displays a string as subscript text.
This method returns the string embedded in the <sub> tag, like this:<sub>string</sub>
None.
A string embedded in the <sub> tag
The following code shows how to Display a string as subscript text:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//w w w .j av a 2 s .c om var str = "Hello World!"; var result = str.sub(); document.getElementById("demo").innerHTML = result; } </script> </body> </html>