Javascript DOM CSS Style outlineColor Property get

Introduction

Return the border color of a <div> element:

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

View in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#myDiv {/*w w  w . j a  v  a 2s  .com*/
  border: 1px solid red;
  outline-style: dotted;
}
</style>
</head>
<body>

<div id="myDiv" style="outline-color:blue;">This is a div element.</div>
<br>
<button type="button" onclick="myFunction()">Return outline color</button>

<p id="demo"></p>
<script>
function myFunction() {
  document.getElementById("demo").innerHTML = document.getElementById("myDiv").style.outlineColor;
}
</script>

</body>
</html>



PreviousNext

Related