如何用 JavaScript 设置一个元素边框的宽度?
若要在 JavaScript 中设置元素边框的宽度,请使用 borderWidth 属性。使用此属性设置宽度。
你可以尝试运行以下代码来了解如何设置元素边框的宽度 −
示例
现场演示<!DOCTYPE html>
<html>
<head>
<style>
#box {
border: thick solid gray;
width: 300px;
height: 200px
}
</style>
</head>
<body>
<div id = "box">Demo Text</div>
<br>
<br>
<button type = "button" onclick = "display()">Change border width</button>
<script>
function display() {
document.getElementById("box").style.borderWidth = "thin";
}
</script>
</body>
</html>
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP