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

Làm cách nào để đặt thuộc tính quy tắc cột bằng JavaScript?


Quy tắc cột thuộc tính được sử dụng trong JavaScript để đặt quy tắc cột. Nó cho phép bạn đặt kiểu, màu sắc và chiều rộng giữa quy tắc cột.

Ví dụ

Bạn có thể thử chạy đoạn mã sau để đặt thuộc tính quy tắc cột bằng JavaScript -

<!DOCTYPE html>
<html>
   <body>
      <p>Click below to create 4 columns</p>
      <button onclick="display()">Columns</button>
      <div id="myID">
         This is demo text. This is demo text. This is demo text. This is demo text.
         This is demo text. This is demo text. This is demo text. This is demo text.
         This is demo text. This is demo text. This is demo text. This is demo text.
         This is demo text. This is demo text. This is demo text. This is demo text.
         This is demo text. This is demo text. This is demo text. This is demo text.
         This is demo text. This is demo text. This is demo text. This is demo text.
         This is demo text. This is demo text. This is demo text. This is demo text.
      </div>
      <script>
         function display() {
            document.getElementById("myID").style.columnCount = "4";
            document.getElementById("myID").style.columnRule = "2px outset red";
         }
      </script>
   </body>
</html>