Javascript DOM HTML Ol Object get

Introduction

The Ol object represents an HTML <ol> element.

We can access an <ol> element via document.getElementById():

var x = document.getElementById("myOl");

Click the button to set the list items to increment from the number "25" instead of "1".

View in separate window

<!DOCTYPE html>
<html>
<body>
<ol id="myOl">
  <li>CSS</li>
  <li>HTML</li>
  <li>Java</li>
</ol>/*from   w ww  .java2 s  .  com*/
<button onclick="myFunction()">Test</button>

<script>
function myFunction() {
  var x = document.getElementById("myOl");
  x.start = "25";
}
</script>

</body>
</html>



PreviousNext

Related