function to set random background color in javascript

Solutions on MaxInterview for function to set random background color in javascript by the best coders in the world

showing results for - "function to set random background color in javascript"
Guadalupe
23 Sep 2016
1function generateRandomColor() {
2  var letters = '0123456789ABCDEF';
3  var color = '#';
4  for (var i = 0; i < 6; i++) {
5    color += letters[Math.floor(Math.random() * 16)];
6  }
7  return color;
8}
9
10var randomColor=generateRandomColor();//"#F10531"
Lilie
09 Feb 2019
1function get_random_color() 
2{
3    var color = "";
4    for(var i = 0; i < 3; i++) {
5        var sub = Math.floor(Math.random() * 256).toString(16);
6        color += (sub.length == 1 ? "0" + sub : sub);
7    }
8    return "#" + color;
9}
10
11function get_rand_color()
12{
13    var color = Math.floor(Math.random() * Math.pow(256, 3)).toString(16);
14    while(color.length < 6) {
15        color = "0" + color;
16    }
17    return "#" + color;
18}
19
Cristóbal
14 Jun 2019
1function random(number){
2    return Math.floor(Math.random()*number);;
3}
4function randomColor(){
5 return 'rgb('+random(255)+','+random(255)+','+random(255)+')';    
6}
Emma
11 Aug 2018
1function random(number){
2    return Math.floor(Math.random()*number);;
3}
4function randomColor(){
5 return 'rgb('+random(255)+','+random(255)+','+random(255)+')';    
6}
7function setRandomColor(){
8    var clr_val=randomColor();
9   // headings.style.color=randomColor();
10    document.body.style.backgroundColor=clr_val;
11
12}
13var btn=document.getElementById("btn");
14btn.addEventListener("click",setRandomColor);
queries leading to this page
js generate random hex colorreturn random color javascriptjs random colour generator redditgenerate random color from string javascriptgetrandomcolorjavascript random color generartorjs return random colorget randon color javascriptgiving object random colour javascruptjavascript randomize colorjavascript create random colorjavacript generate random colorsjavascript style random background colorjs function for random colorsjavascript dandom colorhow to create random colors in javascriptrandom color picker javascriptrandom color generator for jshow to randomize color jshow to check random color in javascriptjs random hex color generatorgenerate random hex color in javascritptake random color in javascriptjacascript randomcolorhow to create a random color code html jshow to generate random color code in javascripthow to use random color in javascriptcreate random color javscriptgetrandom colorrandom hex color code generator in javascriptjs random generate colorjs set random color taggenerate a random color javascriptjs get random colorhow to get random color in javascript in domjs 10 random colorsjavascript random color generatorrandom color in javascriptsjavascript get random color hexes6 randomcolorjs random colorjs function for a random colorhow to produce a random color background in javascriptget random colors jscreate random colors jsjs generate random css colorfunction gives random color js by namejavascript random color variablebuild a random color generatorrandom color function javascriptjs function generate colorjs generates random colorsjs color math randomrandomcolor js generate color jsjavascript random string to colorrandom color generator in javascriptget random color jsrandomly generate colorsjs random rgb colornode get random colourrandom background colors in javascriptjavascript color randomhow to get random color in javascriptrandom hex color generator javascriptjs select random colorjavascript generate colorjavascript random color npmrandom color jsjavascript random colourrandom color javascript coolrandom function for color in javascript 5brandom color 28rgb 3dtrue 2cchange random color javascripthow to math random colorjavascript generate random red colorsjs custom color generatorcolour randomizer js javascropt generate colorpick random color string jschoose random color javascirptfunction to genera random colorhow to use js random background colorhow to use rgb to randomise the color of a box in javascriptjavascript random color generator using math randomgenerate a random color js and displayrandom color generator javascript with timerrandom color generator javascripthow to build coolors javascriptjavascript random color stringjs random color css namedhow to get random colorhow to generate random colors in jsjavascript random nice colorjs generate random colorsrandom color genration in javascriptjs random colourrandom colour generator jshow to give a div random color using javascriptrandom color in javascriptgenerate random colors javascriptrandom color within palette javascriptrandom color image javascriptcreate random color in javascriptmathrandom for colorrandomcolor jsjs generate random color stringchoose random color jsrandom generate hex color javascriptfunction to generate reandom colorjavascript return random colors from a listget random color in javascriptchosse a random color javascriptrandom background color jsrandom color css javascriptrandom color js for a spesific rangehow to generate random color in jsrandom generate color javascriptchoose random color javascriptrandom color javascript from stringjavascript generate random harmonious colorsrandom number generatorhow to declare a random colors variable in jsjavascript generate 2 shades of a random colorfunction to generate random color in javascriptjs generate random colorhow to pick a random color in javascriptjacvasrit generate randon colorget random color from palette javascriptjs get random hex colorjavascript generate random colorjavscipt random coloejavascript random color hex generatorjs random colors from color palettekeep random color change javascripthow to get random dark color in javascriptjs random html colorcolor random jsjavascript generate random colourfunction js random colorjs how to generate random number colorgenerate random color in jsjs color code generatorjavascript assign random color to textcolor generator jsjavascript pick random colorjavascript random simple colorgenerate random color coderandom color function in javascripthow to give random color in javascriptimport random color generator javascriptrandom colors generator jshow to generate a random color in javascripthow to generate random hex color jsjs get random color where alpha 3d0 5random color generator javascript devjavascript random kleurhwo to generate random color in javascriptdynamic color generator how to generate only dark colors javascriptbackground color generator jsgenerate random colors via hex code javascriptrandom color in range jsrandom color javascript elementgenerate random name in jstostring 2816 29 random colorfunction random color javascriptjavascript random coljs generate random html colorrandom color in color array javascriptjavascript generate random colorshow to call a function node js random colorjavascript pick a random colorgenerate random colors string in jshow to generate dynamic color code in javascripthow to generate a random nice looking color in javascriptrandom color code javascriptchange background color randomly javascriptgenerate colors functionrandom color generator function javascriptrandm color javascripthow to generate random color javascriptrandom color changer in jsjavascript get random colorjavascript generate random color from palettehow to get a random color in jsjavascript select random colorgenerate rnadom color jshow to make random color picker using jshow to get a random color in javasriptjavascript random rgb color generatorjs random color generatorrandom color generator in jsrandom unique color generator javascriptcreate random color heading in jsrandomcolor js add 23random background color css decimalrandom hex color javascriptrandom js colorhow to randomly generate a color palette using javascriptrandom color javascript codejs color generate packagegenerate a random color in javascriptjs ramdon de coloreshow to generate random colors i n javascriptrandom color change javascriptrandom colors javascriptrandom color code generator javascriptset elements to a random color jshow to create random rgb palette in javascriptgenerate random dark color javascriptjavascript return random colorhow to generate random colors boxes in javascriptchange random color in javascriptjavascript random color from stringrandom color chooser jsjs reandom colorgenerate random color javascriptjava script choose color by rondom numberjavascript get random color 27javascript random color huehow to generate random background color in javascriptes6 dark color generatorrandom sequqntial colors jsjavascript generate random color hexgenerate random color jsrandom color gen apihow to add random colour from javascript in csselect random color javascriptrandom color chroma jschange random background color in jsto string 16 random colorremove red shade color from html random color random colro jsgenerate random background color javascriptgenerate random colors in jsjs how to random collorsgenerate random color in js variablesjavascript function color randomjavascrtip random colorrandom color code jsjavascript how to generate random hex colorrandom color on load jsget random colors javascriptjs random colorsjavascript random dark color generatorgenerate random color cde 2cjavascriptrandom color generot jsrandom colors jshow to set a js random color variable as a value in cssjavasccipt random colourrandom color htmlcreate random color javascriptjavascript random color hsljavascript random color generator rgbhow to make random color in 3ci 3e using js and cssrandom color hex javascriptrandom colors in javascriptget random color function javascriptrandom colors generator javascriptgenerate random hex color jshow to change color for math random variablejavascript random color from 4hwo to select random color using javascripthow to randomize color in javascriptjquery generate random color codehow to create random color in javascriptpick random color javascripthow to generate random color for an element using javascriptrandom color generator coderabhiies6 random color functionrandom color palette generator javascripthow to make a random color background in javascriptgenerate random color from idhow to get random color in jsjs color generatorrandom color generator coderandom colour generator javascript same colorhow to pick random color htmlhow to make random color in i using js and csshow to make a random color using javascriptjs randomcolorhow to make page with random background color jshow to change random background color in javascripthow to add random colour from javascript in cssgenerate random color hex javascriptrandom color in jshow to generate random colors in javascripthow to get random od color in jshow to get a random color in javascripthow to generate random hex color in javascriptes6 include randomcolorgenerate all 3 bit colors in javascriptgenerate random dark neon color in javascriptauto generate rgb color javascriptjavascript color sequence generatorcode to generate random colours jsrandom color in theme jsget random colorjquery random color rangejavascript random colormath random color javascriptes6 random color function golden ratiogenerate random colors in javascriptjavascript random colorsset random color javascript get random color jsassign random color using javascriptsimple random color generator javascripthow to make color randomnessjavascript generate random color palettehow do i use js to get random colors to different cardcreate a random color jsrandom colors function jsgetrandomcolor jscolors random jsjs random background colorgenerate colors function number ofjjs random colorrandom colour generator javascriptrandom color in javascript not generate blackjs random hex colorutils get random color jshow to randomly print colors without using onclickgenerate random colors in jshow to make a varaible with random color javascriptphp random word generatorjavascrip get random colourrandom css color javascriptjs random color rgbjavascript generate random color based on stringhow to generate random color code in javascript and use it in cssjavascript color randomizerjavascript random graph color generator that looks goodrandom background color javascriptcss js random color generatorcolors js randomhow to make a random color generator in javascriptreandom color generator in jsgenerate a random unique color javascriptjs random nice colorsger random color jsgenerate random color code in javascriptout generate series of colors jsgenerate random hex color javascriptjavascript random colour generatorrandomly generate colors using javascriptrandom colour code generator jsrandom background color in javascriptgenerate random color in javascriptnodejs random colorjavascript color random functionrandom hex color jsrandom color for charecters jsjavascript change background color randomjavascript math random to choose a colorchroma js random colorhow to generate random color in javascript and assign it to a dom elementrandom color generator css 2cjavascript 2chtmlassign random color javascriptrandome colore jshow to get random color javascripthow to choose a random color in javascripthow to write a javascript function to random colorrandom color chart jsnode js random colorgenerating random colorrandom numbers to select random colours javascriptjavascript random color generator never repeatget random color as per keyword javascripthow to make random colors in javascriptjavascript random color changerjquery add random colorjavascript random hex colorhow to make random color in javascriptchange random colors using jschange color randomly javascripthow to generate random color in javascriptcolor generator javascripthow can we get random color from color picker in jsrandomly genaret color in jsrandom color generator jshwo to generate random color using javascxriptrandom colors in javascriptjs set random colorrandomcolorjsjavascript random color generator using math math random colorjavascript paint random colorget random color javascriptrandom color function jsrandom color javascriptrandom hsv generator jsjavascript random hsl colorsjavascript change random background colorfunction to set random background color in javascripthow to random color input javascriptrandom color javascript math formularandom color on click jscreate random color by jsrandom colors in javascript 5chow to give a random color to background using javascriptjavascript generate random comlimentary colorrfunction to set random background color in javascript