Javascript DOM CSS Style outlineWidth Property get

Introduction

Return the width of the outline of a <div> element:

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

View in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#myDiv {/*from  ww  w  .  jav  a2s .co  m*/
  border: 1px solid red;
  outline: dotted green;
}
</style>
</head>
<body>

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

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

</body>
</html>



PreviousNext

Related