使用JavaScript中的width 属性来设置元素的宽度。
您可以尝试运行以下代码以了解如何在JavaScript中设置元素的宽度-
<!DOCTYPE html>
<html>
<body>
<button type="button" id="btn" onclick="display()">
Change height and width
</button>
<script>
function display() {
document.getElementById("btn").style.width = "250px";
document.getElementById("btn").style.height = "250px";
}
</script>
</body>
</html>