点击页面换颜色

代码已经变为body的了,但是为什么老师的课件上会有监听,这东西需要监听么,啊啊啊

----------分割线---------

我只想完成这件事,暂时保存一下代码,除了点小bug,一直不能设置为body,惨、

<!DOCTYPE html>
<html>
<head>
    <title>标题</title>
    <style type="text/css">
        html{background-color:white; height:100%;}
        body{background-color:#eee; height:100%; width:100%; }
        #aa{
            /*
            html{background-color:white; height:100%;}
            body{background-color:#eee; height:100%; width:100%; }
            */
            background-color:#eee;
        }
    </style>
    <script>
        window.onload = function(){
            var cnt=0;
            var obj=document.getElementById("aa");
            obj.onclick= function(){
    //            alert(1);
                   cnt++;
                   cnt=cnt-Math.floor(cnt/3)*3;
                   //alert(cnt);
                   if(cnt==0){
                        obj.style.backgroundColor="#eee";
                   }
                   else if(cnt==1) obj.style.backgroundColor="red";
                   else obj.style.backgroundColor="#000000";
            }
        }
    </script>
</head>
<body  id="aa">
    <!--<div id="aa" ></div>-->
</body>
</html>

 

posted @ 2018-12-24 17:23  啦啦啦天啦噜  阅读(272)  评论(0编辑  收藏  举报