Move a div automatically - add bg image

Move a div automatically - add bg image

by Chandana Thota

HTML

<!-- Move a div automatically - add bg image -->

<div id="cat">
</div>

CSS

#cat{
    position:absolute;
    width:400px;
    height:400px;
    background-color:red;
    left:100px;
    background:url('http://cdn2.scratch.mit.edu/get_image/gallery/248236_170x100.png?v=1378576109.73');
    background-repeat:no-repeat;
    
}

JavaScript

function moveACat() {
 //moving cat from left to right 
$('#cat').css({left:0}); 
    $( "#cat" ).animate({ "left": "+=500" }, 7000 , 'linear',
                        function() {moveACat();
        })
}
  moveACat();