Random Color

by Justin Chen

HTML

<script src="http://desizntech.info/demo/jQuery_color_animation/js/jquery.color.js"></script>
<label>Dies ist ein Test</label>

JavaScript

function startAnimation(o) {
    var hue = 'rgb('
        + (Math.floor(Math.random() * 256)) + ','
        + (Math.floor(Math.random() * 256)) + ','
        + (Math.floor(Math.random() * 256)) + ')';
    $(o.currentTarget).animate( { color: hue }, 500, function() {
        startAnimation(o);
    });
}

$(document).ready(function() {
    $('label').hover(
        startAnimation, 
        function() {
            $(this).stop().animate( { color: '#000' }, 500);
        }
    );
});