如何使用 JavaScript 在一个声明中设置所有边框左侧属性?


要在一个声明中设置所有边框左侧属性,请使用 borderLeft 属性。你可以尝试运行以下代码以了解如何设置边框左侧属性 -

示例

在线演示
<!DOCTYPE html>
<html>
   <head>
      <style>
         #box {
            border: thick solid gray;
            width: 300px;
            height: 200px
         }
      </style>
   </head>
   
   <body>
      <div id = "box">Demo Text</div>
      <br>
      <br>
      
      <button type = "button" onclick = "display()">Change left border</button>
      <script>
         function display() {
            document.getElementById("box").style.borderLeft = "thick solid #000000";
         }
      </script>
      
   </body>
</html>

更新于:2019年7月30日

77 次浏览

开启你的 事业

完成课程,获得认证

开始操作
广告
© . All rights reserved.