如何使用 JavaScript 設定輪廓顏色?


若要設定輪廓顏色,請在 JavaScript 中使用 outlineColor 屬性。你可以嘗試執行以下程式碼以瞭解如何實現 outlineColor 屬性 -

範例

線上演示

<!DOCTYPE html>
<html>
   <head>
      <style>
      #box {
         border: 2px solid red;
      }
      </style>
   </head>
   
   <body>
      <div id = "box">
         Demo Content
      </div>
      <br>
      
      <button type = "button" onclick = "display()">Change outline color</button>
      <script>
         function display() {
            document.getElementById("box").style.outlineColor = "#FF5733";
            document.getElementById("box").style.outline = "2px solid";
         }
      </script>
   </body>
</html>

更新日期:2019 年 7 月 30 日

425 次瀏覽

開啟您的職業生涯

完成課程獲得認證

開始學習
廣告