Javascript DOM CSS Style borderStyle Property set

Introduction

Change the style of the four borders of a <div> element:

document.getElementById("myDiv").style.borderStyle = "dotted solid double dashed";

View in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#myDiv {//  w  w  w . j a v  a2  s .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 four borders</button>

<script>
function myFunction() {
  document.getElementById("myDiv").style.borderStyle = "dotted solid double dashed";
}
</script>

</body>
</html>



PreviousNext

Related