generate random color jquery

Solutions on MaxInterview for generate random color jquery by the best coders in the world

showing results for - "generate random color jquery"
Etan
25 Apr 2018
1$("#btn").click(() => {
2  var colorCode = "1234567890abcdef";
3  var color = "";
4  for (var i = 0; i < 6; i++) {
5    color += colorCode.charAt(Math.floor(Math.random() * colorCode.length));
6  }
7  $("#hex").html("HEX: " + "#" + color); //Display hexacode
8  $("#displaycolor").css("background", "#" + color); //Display color
9});
10