How to return or set the width of the columns with JavaScript?

JavascriptWeb DevelopmentFront End Scripts

Use the JavaScript columnWidth property to set the width of the columns.

Example

You can try to run the following code to set the width of the columns with JavaScript:

Live Demo

<!DOCTYPE html>
<html>
   <body>
      <p>Set the width of the columns</p>
      <button onclick="display()">Change Width</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.
      </div>
      <script>
         function display() {
            document.getElementById("myID").style.columnWidth = "70px";
         }
      </script>
   </body>
</html>
raja
Published on 27-Feb-2018 16:25:29
Advertisements