Return the width of the outline of a <div> element: - Javascript CSS Style Property

Javascript examples for CSS Style Property:outlineWidth

Description

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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#myDiv {//from  ww  w  .j  a  va2s  .c  om
    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>

<script>
function myFunction() {
    console.log(document.getElementById("myDiv").style.outlineWidth);
}
</script>

</body>
</html>

Related Tutorials