<!doctype html><html><head><meta charset="utf-8"><title>javascript</title><style> *margin{margin: 0px;padding: 0px;float: left;} .div1{ width: 400px; height: 400px; background: red; } </style><script> var x=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight; y=document.getElementById("div1"); y.innerHTML="浏览器的高度为"+x+"."; function towidth(){ var oDiv=document.getElementById("div1"); oDiv.style.width=600 px; } function turn(name,value){ var odiv=document.getElementById('div1'); odiv.style[name]=value; } </script></head><body><input type="button" value="变宽" onclick="towidth()"/><input type="button" value="变高" onclick="turn('height','600px')"/><input type="button" value="变绿" onclick="turn('color','green')"/><div class="div1"></div></body></html>
添加回答
举报
0/150
提交
取消