????:<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>div改變css樣式</title><style>#box{width:200px;height: 200px;background: lawn
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>div改變css樣式</title>
<style>
#box{width:200px;height: 200px;background: lawngreen; }
</style>
</head>
<body>
<div id="box"></div>
<input type="button" value="變高" onclick="one()">
<input type="button" value="變寬" onclick="two()">
<input type="button" value="變圓" onclick="tree()">
<input type="button" value="變色" onclick="four()">
<input type="button" value="隱藏" onclick="five()">
<input type="button" value="顯示" onclick="six()">
<script>
var box
window.onload=function(){
box = document.getElementById('box');
}
function one(){
box.style="height:500px;"
}
function two(){
box.style="width:500px;"
}
function tree(){
box.style="border-radius:50%;"
}
function four(){
box.style="background:red;"
}
function five(){
box.style="display:none;"
}
function six(){
box.style="dispaly:black;"
}
</script>
</body>
</html>
?? ???:天蓬老師?? ??:2019-02-02 11:54:40
???? ??:其實 style 的值也是一個對象, 所以可以直接對它的屬性進(jìn)行操作, 這個要注意, 它與其它屬性的值是不同類型