Home > Article > Web Front-end > Introductory example of JavaScript sub method (display string as subscript)_Basic knowledge
JavaScript sub method
Thesub method returns a subscript string defined using the HTML sub tag attribute. Its syntax is as follows:
Tip: This method does not comply with ECMA standards and is not recommended.
sub method instance
Run this example, output:
Tip: This method returns the subscript string defined using the HTML sub tag, even though this method cannot directly change the string to a subscript style. If you want to dynamically change the element font to a subscript style, you can refer to the following example:
Change the font text top and bottom alignment (superscript/subscript)
Subscript style Superscript style
Script HouseEvery bit of progress is a solid footprint on our road to success
In this example, JavaScript is used to control the text CSS vertical-align style to dynamically change the upper and lower alignment (superscript/subscript) of the font text.