Change the color of the left border of a <div> element to red:
document.getElementById("myDiv").style.borderLeftColor = "red";
<!DOCTYPE html> <html> <head> <style> #myDiv {//from w w w .jav a2s .co m border: thick solid blue; } </style> </head> <body> <div id="myDiv">This is a div element.</div> <br> <button type="button" onclick="myFunction()">Change color of the left border</button> <script> function myFunction() { document.getElementById("myDiv").style.borderLeftColor = "red"; } </script> </body> </html>
The borderLeftColor property sets or gets the color of the left border of an element.
Property Values
Value | Description |
---|---|
color | Set the color of the left border. Default color is black |
transparent | The color of the left border is transparent |
initial | Sets this property to its default value. |
inherit | Inherits this property from its parent element. |
The borderLeftColor property returns a String representing the color of an element's left border.