以下是我一个刚学js总结的一些基础知识点,我认为写代码最重要的是日积月累的代码量。这是我总结的
<body的最末端 在这里写js代码>
<script>console.log("你好呀,每天开心!");
<\script>
for(var j=0;j<all.length;j++){
all[j].style.backgroundColor = cs[i];
}
#fff!important带!表示重点不变
transparent;
var all=document.querSelectorAll('.wai div');//全部元素--集合/数组
i++;
0-7随机整数floor
Math.random()*7
for(i=1;i<100;i++){console.log(i)};
在控制台上写 a=1111 a.tostring(16)16进制
console.log(你好啊,天天开心); 天天开心
function bian(i){ //指定第i个元素变颜色
var cs=['red','blue','pink','green'];
var all=document.querySelectorAll(".wai div");
//Math.floor(Math.random()*7===>0-6的随机数)
all[i].style.backgroundColor=cs[Math.floor(Math.random()*7)];
}
//每隔1000毫秒,调用bian(0)
setInterval(bian,1000,0)
//延时执行
setTimeout(bian,1000,0)
将html中的一个色块改变延迟i秒然后开始启动变色程序
for(var i=0;i<all.length;i++){
setTimeout( function(j){setInterval(bian,1000,j)},1000*i, i);//延迟1000*i秒
}