abstrak:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>改變DIV樣式</title
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>改變DIV樣式</title> <script> // 聲明全局變量,讓后面函數(shù)共同調(diào)用 var box1 window.onload=function(){ box1 =document.getElementById('box'); }; // 去調(diào)用全局變量 function one() { box1.style.height='300px'; }; function two() { box1.style.width='300px'; }; function there() { box1.style.background='lightpink'; }; function four() { box1.style.width='150px'; box1.style.height='150px'; box1.style.background='lightskyblue'; }; function five() { box1.style.display='none'; }; function six() { box1.style.display='block'; } </script> <style> #box{width: 150px;height: 150px;background: lightskyblue;margin:10px 60px} </style> </head> <body> <div id="box"></div> <button onclick="one()">變高</button> <button onclick="two()">變寬</button> <button onclick="there()">變色</button> <button onclick="four()">重置</button> <button onclick="five()">隱藏</button> <button onclick="six()">顯示</button> </body> </html>
Guru membetulkan:查無(wú)此人Masa pembetulan:2019-05-05 09:09:08
Rumusan guru:完成的不錯(cuò)。js比較難,因?yàn)樗墓δ芊浅?qiáng)大。繼續(xù)加油。