Javascript DOM CSS Style borderRight Property set

Introduction

Change the width, style and color of the right border of a <div> element:

document.getElementById("myDiv").style.borderLeft = "thin dotted red";

View in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#myDiv {/*from   ww w  .ja  va2s  .  c o  m*/
  border: thick solid blue;
}
</style>
</head>
<body>

<div id="myDiv">This is a div element.</div>
<br>
<button type="button" onclick="myFunction()">Change right border</button>

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

</body>
</html>



PreviousNext

Related