$(document).ready(function() {
var randomRed = Math.floor(Math.random() * 255);
var randomGreen = Math.floor(Math.random() * 255);
var randomBlue = Math.floor(Math.random() * 255);
$('p').mouseover(function() {
$('p').css('color', 'rgb(' + randomGreen + ',' + randomBlue + ',' + randomRed + ')');
});
$('p').mouseout(function() {
$('p').css('color', 'black');
});
});
I have the above code which generates a random color on mouseover, then returns it to black on mouseout, which works fine. However it generates the same random color on every mouseover.
How do I make it so that it generates a different random color on every mouseover event??
Try like this