<!DOCTYPE HTML>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<script>
$(function()
{
$('#container')
.mousedown(function()
{
$('#conveyor').data('moveInterval',setInterval(function()
{
$('#conveyor').offset({left: ++$('#conveyor').offset().left })
},50));
})
.mouseup(function()
{
clearInterval($('#conveyor').data('moveInterval'));
});
});
</script>
<style>
#container{
height: 50px;
width: 100%;
background-color: yellow;
}
#conveyor{
position: relative;
height: 100%;
width: 50px;
background-color: green;
}
</style>
</head>
<body>
Click on yellow block:
<div id="container">
<div id="conveyor"></div>
</div>
</body>
</html>