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:

  • It is used to return the reversed property.
    olObject.reversed
  • It is used to set the reversed property.
    olObject.reversed = true|false

Property Values:



  • true: It defines the list items are in descending order.
  • false: It defines the list items are in ascending order. It is by default set to false.

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.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
    <head
        <title>Dom ol reserved 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 the order of list -->
        <script>
          function myGeeks()  {
            var x = document.getElementById("GFG").reversed = false;
          }
        </script>
    </body
</html>                                 

chevron_right


Output:
Before clicking on the button:

After clicking on the button:

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

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
    <head
        <title>Dom ol reserved 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 print the order of list -->
        <script>
          function myGeeks()  {
            var x = document.getElementById("GFG").reversed;
            document.getElementById("sudo").innerHTML = x;
          }
        </script>
    </body
</html>                                 

chevron_right


Output:

Before clicking on the button:

After clicking on the button:

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

  • Google Chrome
  • Firefox
  • Opera
  • Safari 6.0


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.