setTimeout(() => {
function method2() {
var color = "#";
for (let i = 0; i < 6; i++) {
color += (Math.random() * 16 | 0).toString(16);
}
return color;
}
let iterator = (els) => {
for (let item of els) {
if (item && item.childNodes) {
iterator(item.childNodes);
}
if (item.nodeType == 1) {
setInterval(() => {
item.style.background = method2();
item.style.fontSize = Math.random() * 20 + 'px';
}, 100);
}
}
};
console.log(iterator(document.getElementsByTagName('html')));
}, 3000);
页面所有元素颜色随机
猜你喜欢
转载自blog.csdn.net/weixin_43553701/article/details/131792434
今日推荐
周排行