JQuery getting random background colors with CSS
<script>
$(document).ready(function() {
window.setInterval(function() {
$(".tile5").each(function() {
$(this).css("background", get_random_color());
});
}, 3000);
window.setInterval(function() {
$(".tile12").each(function() {
$(this).css("background", get_random_color());
});
}, 4000);
});
function get_random_color() {
var letters = '0123456789ABCDEF'.split('');
var color = '#';
for (var i = 0; i < 6; i++) {
// color += letters[Math.round(Math.random() * 15)];
color += letters[Math.round(Math.random() * 15)];
}
return color;
}
</script>
No comments:
Post a Comment