Widziałem wiele miejsc za pomocą Math.floor()
i Math.random()
Wyjaśnij Math.floor (Math.random())
jak poniżej
$('a.random-color').hover(function() { //mouseover
var col = 'rgb(' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ')';
$(this).animate({
'color': col,
'paddingLeft': '20px'
},1000);
},function() { //mouseout
$(this).animate({
'color': original,
'paddingLeft': '0'
},500);
});
});
Dlaczego stosować Math.floor()
i Math.random()
?