HTML DOM borderTopColor 属性
JavaScript基础 2022-06-08 14:25:27小码哥的IT人生shichen
HTML DOM borderTopColor 属性
定义和用法
borderTopColor 属性设置元素上边框的颜色。
语法:
Object.style.borderTopColor=color-name|color-RGB|color-hex
实例
本例改变段落的上边框的颜色:
<html>
<head>
<style type="text/css">
p
{
border: thick solid #FF0000
}
</style>
<script type="text/javascript">
function changeBorderColor()
{
document.getElementById("p1").style.borderTopColor="#0000FF";
}
</script>
</head>
<body>
<input type="button" onclick="changeBorderColor()"
value="Change paragraph border color" />
<p id="p1">This is a paragraph</p>
</body>
</html>
TIY
完整实例【borderTopColor - 改变段落的上边框的颜色】:
<html>
<head>
<style type="text/css">
p
{
border: thick solid #FF0000
}
</style>
<script type="text/javascript">
function changeBorderColor()
{
document.getElementById("p1").style.borderTopColor="#0000FF";
}
</script>
</head>
<body>
<input type="button" onclick="changeBorderColor()" value="Change top border color" />
<p id="p1">This is a paragraph</p>
</body>
</html>
可以使用本站在线JavaScript测试工具测试上述代码运行效果:http://www.phpcodeweb.com/runjs.html