abstrakt:<!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>
Korrigierender Lehrer:天蓬老師Korrekturzeit:2019-02-02 11:54:40
Zusammenfassung des Lehrers:其實(shí) style 的值也是一個(gè)對(duì)象, 所以可以直接對(duì)它的屬性進(jìn)行操作, 這個(gè)要注意, 它與其它屬性的值是不同類(lèi)型