点击页面换颜色

代码已经变为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>

 

转载于:https://www.cnblogs.com/lalalatianlalu/p/10169815.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值