ในการตั้งค่าความกว้างของเส้นขอบบนใน JavaScript ให้ใช้ borderTopWidth คุณสมบัติ. กำหนดความกว้างของเส้นขอบด้านบนโดยใช้คุณสมบัตินี้
ตัวอย่าง
คุณสามารถลองใช้โค้ดต่อไปนี้เพื่อเรียนรู้วิธีตั้งค่าความกว้างของเส้นขอบด้านบนด้วย JavaScript -
<!DOCTYPE html>
<html>
<head>
<style>
#box {
border: thick solid blue;
width: 300px;
height: 300px;
}
</style>
</head>
<body>
<div id="box">Demo Text</div>
<br><br>
<button type="button" onclick="display()">Change top border width</button>
<script>
function display() {
document.getElementById("box").style.borderTopWidth = "10px";
}
</script>
</body>
</html>