Add a "solid" top border to a <div> element:
document.getElementById("myDiv").style.borderTopStyle = "solid";
<!DOCTYPE html> <html> <body> <div id="myDiv">This is a div.</div> <br> <button type="button" onclick="myFunction()">Set solid top border</button> <script> function myFunction() {//from w ww .j av a 2s . com document.getElementById("myDiv").style.borderTopStyle = "solid"; } </script> </body> </html>
The borderTopStyle property sets or gets the style of the top border of an element.
Property Values
Value | Description |
---|---|
none | Defines no border. This is default |
hidden | Same as "none" |
dotted | a dotted border |
dashed | a dashed border |
solid | a solid border |
double | two borders. |
groove | a 3D grooved border. |
ridge | a 3D ridged border. |
inset | a 3D inset border. |
outset | a 3D outset border. |
initial | Sets this property to its default value. |
inherit | Inherits this property from its parent element. |
The borderTopStyle property returns a String representing the style of an element's top border.