Pages

Getting random background colors with JQuery

JQuery getting random background colors with CSS

Getting random background colors with JQuery


<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

Search This Blog