Javascript DOM CSS Style borderTopColor Property get

Introduction

Return the top border color of a <div> element:

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

View in separate window

<!DOCTYPE html>
<html>
<body>

<div id="myDiv" style="border-top:thick solid green">This is a div.</div>
<br>
<button type="button" onclick="myFunction()">Return top border color</button>

<p id="demo"></p>
<script>
function myFunction() {/*  w w  w.  ja  va2 s  .c o m*/
  document.getElementById("demo").innerHTML = document.getElementById("myDiv").style.borderTopColor;
}
</script>

</body>
</html>



PreviousNext

Related