Change the style of the top border of a <div> element to "dotted": - Javascript CSS Style Property

Javascript examples for CSS Style Property:borderTopStyle

Description

Change the style of the top border of a <div> element to "dotted":

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#myDiv {//  w  w  w . jav  a2s.  c  o  m
    border: thick solid #FF0000;
}
</style>
</head>
<body>

<div id="myDiv">This is a div.</div>
<br>
<button type="button" onclick="myFunction()">Change style of the top border</button>

<script>
function myFunction() {
    document.getElementById("myDiv").style.borderTopStyle = "dotted";
}
</script>

</body>
</html>

Related Tutorials