How to set the column rule properties with JavaScript?

JavascriptWeb DevelopmentFront End Scripts

The columnRule property is used in JavaScript to set the column rule. It allows you to set the style, color, and width between column rule.

Example

You can try to run the following code to set the column rule properties with JavaScript −

Live Demo

<!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>
raja
Published on 27-Feb-2018 16:05:26
Advertisements