How to set outline color with JavaScript?


To set outline color, use the outlineColor property in JavaScript. You can try to run the following code to learn how to implement outlineColor property −

Example

Live Demo

<!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>

Sai Subramanyam
Sai Subramanyam

Passionate, Curious and Enthusiastic.

Updated on: 30-Jul-2019

345 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements