跟着老师的思想写的代码简洁而且不冗余

原创 2019-01-06 10:54:53 289
摘要:代码简洁不冗余<!DOCTYPE html><html><head lang="en">    <meta charset="UTF-8">    <title></title>    <style type="

代码简洁不冗余


QQ截图20190106105348.png

<!DOCTYPE html>
<html>
<head lang="en">
   <meta charset="UTF-8">
   <title></title>
   <style type="text/css">
       #box{width: 100px;height: 100px;margin: 30px;background-color: red}
   </style>
   <script type="text/javascript">
       var box
       window.onload=function(){
           box=document.getElementById('box')
       }
       function a(){
          box.style.height="500px"
}
       function b(){
           box.style.width="500px"
}
       function c(){
           box.style.backgroundColor="blue"
}
       function d(){
           box.style.width="100px"
box.style.height="100px"
box.style.backgroundColor="red"
box.style.display="block"
}
       function e(){
           box.style.display="none"
}
       function f(){
           box.style.display="block"
}
   </script>
</head>
<body>
<div id="box"></div>
<input type="button" value="变高" onclick="a()"/>
<input type="button" value="宽" onclick="b()"/>
<input type="button" value="变色" onclick="c()"/>
<input type="button" value="重置" onclick="d()"/>
<input type="button" value="隐藏" onclick="e()"/>
<input type="button" value="显示" onclick="f()"/>
</body>
</html>

批改老师:灭绝师太批改时间:2019-01-06 11:51:49
老师总结:除了函数名将就点,其他没毛病!你不可以跟老师测试一样这样写函数名呦!

发布手记

热门词条