The outlineColor
property sets or gets
the color of the outline.
outlineColor |
Yes | 9.0 | Yes | Yes | Yes |
Return the outlineColor property:
var v = object.style.outlineColor
Set the outlineColor property:
object.style.outlineColor='color|invert|initial|inherit'
Value | Description |
---|---|
color | Set the outline color. |
invert | Default. Invert the outline color to the opposite value. |
initial | Set to default value. |
inherit | Inherit from parent element. |
Default Value: | invert |
---|---|
Return Value: | A string representing the outline color |
CSS Version | CSS2 |
The following code shows how to change the outline color.
<!DOCTYPE html>
<html>
<head>
<style>
#myDiv {<!--from w w w .ja v a2 s . c om-->
border: 1px solid red;
outline-style: dotted;
}
</style>
</head>
<body>
<div id="myDiv">This is a div element.</div>
<button type="button" onclick="myFunction()">test</button>
<script>
function myFunction() {
document.getElementById("myDiv").style.outlineColor = "#00ff00";
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to get the outline color.
<!DOCTYPE html>
<html>
<head>
<style>
#myDiv {<!-- w w w. ja v a 2 s . com-->
border: 1px solid red;
outline-style: dotted;
}
</style>
</head>
<body>
<div id="myDiv" style="outline-color:blue;">This is a div element.</div>
<button type="button" onclick="myFunction()">test</button>
<script>
function myFunction() {
console.log(document.getElementById("myDiv").style.outlineColor);
}
</script>
</body>
</html>
The code above is rendered as follows: