Test
HTML
<button>Animate</button>
<div class="box first" style="background:#DC143C;"></div>
<div class="box second" style="background:#CD5C5C;"></div>
<div class="box third" style="background:#FF69B4;"></div>
<div class="box fourth" style="background:#FF7F50"></div>
CSS
.box {
margin: 10px;
height: 100px;
width: 100px;
}
JavaScript
$(function(){
var box = $('div');
setInterval(function() {
var margin = parseInt(box.css('marginLeft'), 10);
box.css({
"margin-left": margin + 10 + 'px'
});
$('div.box.first').on('click', function() {
$(this).height(50);
$(this).width(50)
});
$('div.box.third').on('mouseenter', function() {
$(this).css({'background-color' : '#ccc'});
}).on('mouseleave', function() {
$(this).css({'background-color' : '#FF69B4'});
});
}, 1000);
});