1. 程式人生 > >點選頁面換顏色

點選頁面換顏色

我只想完成這件事,暫時儲存一下程式碼,除了點小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>