小码哥的IT人生

HTML DOM outlineColor 属性

JavaScript基础 2022-06-08 14:48:19小码哥的IT人生shichen

HTML DOM outlineColor 属性

定义和用法

outlineColor 属性设置元素周围的轮廓的颜色。

语法:

Object.style.outlineColor=color-name|color-rgb|color-hex

实例

本例改变轮廓的颜色:

<html>
<head>
<style type="text/css">
p
{
border: thin solid #00FF00;
outline: thick solid #FF0000;
}
</style>
<script type="text/javascript">
function changeOutlineColor()
{
document.getElementById("p1").style.outlineColor="#00FF00";
}
</script>
</head>
<body>
<input type="button" onclick="changeOutlineColor()"
value="Change outline color" />
<p id="p1">This is a paragraph</p>
</body>
</html>

TIY

完整实例【outlineColor - 改变围绕元素的轮廓的颜色】:

<html>
<head>
<style type="text/css">
p
{
border: thin solid #00FF00;
outline: thick solid #FF0000;
}
</style>
<script type="text/javascript">
function changeOutlineColor()
{
document.getElementById("p1").style.outlineColor="#00FF00";
}
</script>
</head>
<body>
<input type="button" onclick="changeOutlineColor()" value="Change outline color" />
<p id="p1">This is a paragraph</p>
</body>
</html>

可以使用本站在线JavaScript测试工具测试上述代码运行效果:http://www.phpcodeweb.com/runjs.html

(请在非 IE 浏览器中浏览)

版权所有 © 小码哥的IT人生
Copyright © phpcodeweb All Rights Reserved
ICP备案号:苏ICP备17019232号-2  

苏公网安备 32030202000762号

© 2021-2024