代码示例:(标识:htmldom_sub_get)
<!DOCTYPE html>
<html>
<body>

<h3>如何访问 SUB 元素的演示</h3>

<p>点击按钮将 <sub id="mySub">此下标文本</sub> 的颜色设置为红色。</p>

<button onclick="myFunction()">试一试</button>

<script>
function myFunction() {
  var x = document.getElementById("mySub");
  x.style.color = "red";
}
</script>

</body>
</html>
运行结果: