Javascript DOM HTML Ol reversed Property set

Introduction

Set the list order to descending:

document.getElementById("myOl").reversed = true;

Click the button to set the list order to descending (9, 8, 7...) instead of ascending (1, 2, 3...).

View in separate window

<!DOCTYPE html>
<html>
<body>

<ol id="myOl">
  <li>CSS</li>
  <li>HTML</li>
  <li>Java</li>
  <li>Javascript</li>
  <li>SQL</li>
</ol>/*from  w ww.  j  a  va 2 s.co m*/
<button onclick="myFunction()">Test</button>

<script>
function myFunction() {
  document.getElementById("myOl").reversed = true;
}
</script>

</body>
</html>

The reversed property sets or gets whether the list order should be descending or not.

Value Description
true The list order is descending
false Default. The list order is ascending

The reversed property returns true if the list order is descending, otherwise it returns false.




PreviousNext

Related