📌  相关文章
📜  javascript 生成随机颜色 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:51.036000             🧑  作者: Mango

代码示例6
const setBg = () => {
  const randomColor = Math.floor(Math.random()*16777215).toString(16);
  document.body.style.backgroundColor = "#" + randomColor;
  color.innerHTML = "#" + randomColor;
}

genNew.addEventListener("click", setBg);
setBg();