Javascript examples for DOM HTML Element:Subscript
You can create a <sub> element by using the document.createElement() method:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">create a SUB element with some text</button> <script> function myFunction() {/* w w w . j av a2 s. c om*/ var x = document.createElement("SUB"); var t = document.createTextNode("This text contains subscript text"); x.appendChild(t); document.body.appendChild(x); } </script> </body> </html>