abstrak:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>用javascript改變DIV實(shí)例</title> <style type="text/css"> #box{widt
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>用javascript改變DIV實(shí)例</title> <style type="text/css"> #box{width:100px;height:100px;background:red;margin:20px 80px;} </style> </head> <body> <script type="text/javascript"> var box window.onload=function(){ box=document.getElementById('box') } function changeheight(){ box.style.height="200px" } function changewidth(){ box.style.width="200px" } function changecolor(){ box.style.background="green" } function reset(){ box.style.width="100px" box.style.height="100px" box.style.background="red" } function yc(){ box.style.display="none" } function xs(){ box.style.display="block" } </script> <div id="box"></div> <input type="button" value="變高" onclick="changeheight()"> <input type="button" value="變寬" onclick="changewidth()"> <input type="button" value="變色" onclick="changecolor()"> <input type="button" value="重置" onclick="reset()"> <input type="button" value="隱藏" onclick="yc()"> <input type="button" value="顯示" onclick="xs()"> </body> </html> <!-- 擴(kuò)展:就現(xiàn)在所學(xué)的知識(shí),想實(shí)現(xiàn)點(diǎn)一次變高按鈕,增加一次高度,再點(diǎn)一次變高按鈕,再次增加高度這樣的效果,好像還是不行。 -->
Guru membetulkan:滅絕師太Masa pembetulan:2018-12-29 13:16:30
Rumusan guru:循環(huán)一下就可以,沒(méi)有什么是不可以噠,就是沒(méi)有啥實(shí)際意義