еще вариант
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
div { background-color:green; height:100px; width:100px; }
</style>
<script type="text/javascript">
var i = 0;
function x() {
if (i<400) {
document.getElementsByTagName('div')[0].style.marginLeft=++i+'px';
setTimeout(x,10);
}
}
</script>
</head>
<body>
<div onclick="x();"></div>
</body>
</html>