Javascript DOM CSS Style borderTopStyle Property set

Introduction

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

document.getElementById("myDiv").style.borderTopStyle = "dotted";

View in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#myDiv {//  www . j a  va2 s .com
  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>



PreviousNext

Related