Get Subscript Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Subscript

Introduction

The Subscript object represents an HTML <sub> element.

You can access a <sub> element by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<sub id="mySub">this subscript text</sub>

<button onclick="myFunction()">set the color</button>

<script>
function myFunction() {//from www  .j  ava2s .  c o  m
    var x = document.getElementById("mySub");
    x.style.color = "red";
}
</script>

</body>
</html>

Related Tutorials