I'm creating a WordPress website where I give a random color to each publish background. The code I'm using is below:

// Background color animation 
$(document).ready(function(){
    $(".texts").hover(function() {

    },function() {
        $(this).animate({ color: "#FFFFFF" }, 500);
    });

    // Fun with Color. Differnt font color each time hover
    // Original code can be found http://davidwalsh.name/jquery-random-color-animate
    original = $('.texts').css('background-color');

    $('.texts').hover(function() { //mouseover
        var col = 'rgb(' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ')';
        $(this).stop().animate({'backgroundColor': col}, 1000);
    },function() { //mouseout
        $(this).stop().animate({'backgroundColor': original},500);
    });

    $('.texts').hover(function() { //mouseover
        var col = 'rgb(' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ')';
        $(this).animate({'backgroundColor': col},500);
    },function() { //mouseout
        $(this).animate({'backgroundColor': col},500);
    });
});

More code where I'm using Ajax to load more posts within the home page code is below:

var href = 'first';
$(document).ready(function() {
    $('#boxes').infinitescroll({
        navSelector : '.infinitescroll',
        nextSelector : '.infinitescroll a',
        itemSelector : '#boxes .box',
        loadingImg : '<?php echo get_bloginfo('stylesheet_directory') ?>/images/loading.gif',
        loadingText : 'Loading...',
        donetext : 'No more pages to load.',
        debug : false
    }, function(arrayOfNewElems) {
        $('#boxes').masonry('appended', $(arrayOfNewElems));
        if (href != $('.infinitescroll a').attr('href')) {
            href = $('.infinitescroll a').attr('href');
        }
    });
});

And however , the page2 publish (after ajax load), can't add the jQuery class to div.texts.

How do i fix this?