MasterRO94
11/25/2016 - 2:06 PM

crazyBg.js

function makeCraziness() {
    function makeCrazy($el) {
        if ($el.children().length) {
            $el.children().each(function() {
                makeCrazy($(this));
            });
        }

        $el.css({
            color: getRandomColor(),
            background: getRandomColor(),
            transition: 'all .5s ease',
        });
    }


    $(document).on('mousemove', function() {
        makeCrazy($(this));
    });
}

function getRandomColor() {
    let letters = '0123456789ABCDEF';
    let color = '#';

    for (let i = 0; i < 6; i++ ) {
        color += letters[Math.floor(Math.random() * 16)];
    }

    return color;
}