如何透過 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>

更新於: 30-Jul-2019

77 次瀏覽

開啟你的 職業旅程

完成課程以獲得認證

立即開始
廣告
© . All rights reserved.