Javascript DOM CSS Style borderTop Property get

Introduction

Return the border-top property values of a <div> element:

alert(document.getElementById("myDiv").style.borderTop);

View in separate window

<!DOCTYPE html>
<html>
<body>

<div id="myDiv" style="border-top:5px solid red;">This is a div element.</div>
<br>
<button type="button" onclick="myFunction()">Return top border</button>

<p id="demo"></p>
<script>
function myFunction() {//from  w  ww . j a  v  a 2s. c  o  m
  document.getElementById("demo").innerHTML = document.getElementById("myDiv").style.borderTop;
}
</script>

</body>
</html>



PreviousNext

Related