I am using this Math for a bg color animation on hover:
var col = 'rgb(' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ')';
It produces a random rgb color. Very nice indeed but I look for something different.
Does anybody know a good Math that I can use to have that random color only out of a certain color range, like out of the red color range or out of the greens?
Any help is appreciated.
@Avinash, here is my complete code as I use it right now. How can I include your solution?
$(document).ready(function(){
//bg color animation
original = $('.item,.main-menu-button').css('background-color');
$('.item,.main-menu-button').hover(function() { //mouseover
var col = 'rgb(' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ')';//random hover color
$(this).stop().animate({'backgroundColor': col}, 1000);
},function() { //mouseout
$(this).stop().animate({'backgroundColor': '#111'},500);//original color as in css
});
I doesn´t work. I better leave it as it is. Thank to all of you for your help.