<html>
<head>
<style>
div {
width: 40px;
height: 40px;
border:1px solid #777;
margin-top: 0;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
$(function() {
var direction = 0;
$('button').click(function() {
direction ^= 1;
$('#as').animate({
marginTop: 320 * direction
}, 800)
});
});
</script>
</head>
<body>
<div id="as"></div>
<button>GO</button>
</body>
</html>