Javascript DOM CSS Style borderWidth Property with two values

Introduction

Change the width of the top and bottom border to thick, and the left and right border to thin of a <div> element:

document.getElementById("myDiv").style.borderWidth = "thick thin";

View in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#myDiv {//from  ww  w.j  ava  2  s.  c o  m
  border-style: solid;
}
</style>
</head>
<body>

<div id="myDiv">This is a div element.</div>
<br>
<button type="button" onclick="myFunction()">Change width of the four borders</button>

<script>
function myFunction() {
  document.getElementById("myDiv").style.borderWidth = "thick thin";
}
</script>

</body>
</html>



PreviousNext

Related