Computer >> Máy Tính >  >> Lập trình >> HTML

Thuộc tính HTML DOM Ol đã đảo ngược

Thuộc tính HTML DOM Ol đã đảo ngược đặt / trả về liệu thứ tự danh sách nên giảm dần hay tăng dần (mặc định).

Sau đây là cú pháp -

Trả về giá trị boolean - true / false

olObject.reversed

Cài đặt đã đảo ngược thành booleanValue

olObject.reversed = booleanValue

Đây, “ booleanValue” có thể như sau -

booleanValue
Chi tiết
true
Nó xác định thứ tự sẽ giảm dần
false
Nó xác định rằng thứ tự sẽ tăng dần là mặc định

Hãy để chúng tôi xem một ví dụ về Ol đã đảo ngược tài sản -

Ví dụ

<!DOCTYPE html>
<html>
<head>
<title>HTML DOM Ol reversed</title>
<style>
   form {
      width:70%;
      margin: 0 auto;
      text-align: center;
   }
   * {
      padding: 2px;
      margin:5px;
   }
   input[type="button"] {
      border-radius: 10px;
   }
   ol{
      width: 30%;
      margin: 0 auto;
   }
</style>
</head>
<body>
   <form>
      <fieldset>
         <legend>HTML-DOM-Ol-reversed</legend>
         <h3>Students</h3>
         <ol id="orderList">
            <li>Zampa</li>
            <li>Rajesh</li>
            <li>Eden</li>
            <li>Bina</li>
            <li>Alex</li>
            <li>Adam</li>
         </ol>
         <input type="button" onclick="reverseNumbering()" value="Correct list">
         <div id="divDisplay"></div>
      </fieldset>
   </form>
<script>
   var divDisplay = document.getElementById("divDisplay");
   var studentList = document.getElementById("orderList");
   function reverseNumbering() {
      studentList.reversed = true;
      divDisplay.textContent = 'List Corrected';
   }
</script>
</body>
</html>

Đầu ra

Trước khi nhấp vào ‘Danh sách đúng’ nút -

Thuộc tính HTML DOM Ol đã đảo ngược

Sau khi nhấp vào ‘Danh sách chính xác’ nút -

Thuộc tính HTML DOM Ol đã đảo ngược