如何使用 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.