Open In App

HTML | DOM Ol reversed Property

The DOM Ol reversed Property is used to set or return whether the list items are in Descending order(9, 8, 7, 6, …) or in Ascending order(1, 2, 3, 4…).

Syntax: 



olObject.reversed
olObject.reversed = true|false

Property Values: 

Return Value: It returns a Boolean value which represent the order i.e descending or ascending the list items.



Example-1: HTML Program that illustrate how to set the Property.  




<!DOCTYPE html>
<html>
<head>
    <title>Dom ol reversed Property</title>
</head>
<body>
    <h1 style="color:green;">
        GeeksforGeeks</h1>
    <h2 style="color:green;">
        DOM ol reversed Property
    </h2>
     
<p>List of all computer Subjects are</p>
 
    <ol id="GFG" reversed>
        <li>Data Structures</li>
        <li>Operating System</li>
        <li>python programming</li>
        <li>DBMS</li>
        <li>Computer Network</li>
    </ol>
    <button onclick="myGeeks()">Submit</button>
 
    <!-- Script to set ol reversed Property -->
    <script>
        function myGeeks() {
            var x = document.getElementById("GFG").reversed = false;
        }
    </script>
</body>
</html>

Output: 
Before clicking on the button: 

After clicking on the button: 

Example-2: HTML program that illustrate how to return the property. 




<!DOCTYPE html>
<html>
<head>
    <title>Dom ol reversed Property</title>
</head>
<body>
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
    <h2 style="color:green;">
        DOM ol reversed Property
    </h2>
     
<p>List of all computer Subjects are</p>
 
    <ol id="GFG" reversed>
        <li>Data Structures</li>
        <li>Operating System</li>
        <li>python programming</li>
        <li>DBMS</li>
        <li>Computer Network</li>
    </ol>
    <button onclick="myGeeks()">Submit</button>
    <p id="sudo" style="font-size:25px;
        color:green;text-align:center;">
    </p>
 
 
    <!-- Script to return the ol reversed property -->
    <script>
        function myGeeks() {
            var x = document.getElementById("GFG").reversed;
            document.getElementById("sudo").innerHTML = x;
        }
    </script>
</body>
</html>

Output: 
Before clicking on the button: 

After clicking on the button: 

Supported Browsers: The browser supported by DOM ol reversed Property are listed below: 


Article Tags :