Result Size: 625 x 534
x
 
<!DOCTYPE html>
<html>
<head>
<style> 
#myDIV {
  border: 1px solid black;
  width: 300px;
  height: 300px;
}
</style>
</head>
<body>
<h1>使用 JavaScript 更改顶部边框</h1>
<p>点击“试一试”按钮更改 DIV 元素的 border-top 属性:</p>
<button onclick="myFunction()">试一试</button>
<div id="myDIV">
  <h1>Hello</h1>
</div>
<script>
function myFunction() {
  document.getElementById("myDIV").style.borderTop = "3px dashed lightblue";
}
</script>
</body>
</html>