如何使用JavaScript更改要显示为下标的字符串?
若要使用JavaScript更改要显示为下标的字符串,请使用sub()方法。此方法使字符串显示为下标,就像在<sub>标记中一样。
示例
您可以尝试运行以下代码来更改要显示为下标的字符串-
<html>
<head>
<title>JavaScript String sub() Method</title>
</head>
<body>
<script>
var str = new String("Demo Text");
document.write("This is subscript: "+str.sub());
</script>
</body>
</html>