📜  生成随机颜色 jquery - Javascript 代码示例

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

代码示例1
$("#btn").click(() => {
  var colorCode = "1234567890abcdef";
  var color = "";
  for (var i = 0; i < 6; i++) {
    color += colorCode.charAt(Math.floor(Math.random() * colorCode.length));
  }
  $("#hex").html("HEX: " + "#" + color); //Display hexacode
  $("#displaycolor").css("background", "#" + color); //Display color
});