Gerar cor aleatória

jQuery.gerarCorAleatoria = function(){ function aleatorio(inferior,superior){ numPossibilidades = superior - inferior aleat = Math.random() * numPossibilidades aleat = Math.floor(aleat) return parseInt(inferior) + aleat } hexadecimal = new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F") cor_aleatoria = "#"; for (i=0;i<6;i++){ posarray = aleatorio(0,hexadecimal.length) cor_aleatoria += hexadecimal[posarray] } return cor_aleatoria };
Retorna cor aleatoria em hexadecimal como (#3C7697);

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.