Forum Moderators: open
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Animate me</title>
<style type="text/css">
#container {
width: 600px;
height: 400px;
margin: 100px auto;
position: relative;
border: 1px solid #000;
}
#container a {
display: block;
width: 300px;
height: 120px; position:
absolute;
top: 140px;
left: 150px;
outline:none;
}
img { border: none; }
</style>
<script type="text/javascript" src="jquery-1.4.3.min.js"></script>
<script type="text/javascript">
$(function(){
$('#container a').click(function() { return move_box(); });
});
//
function move_box() {
var curr_top=$('#container a').css('top');
var move_to=(parseInt(curr_top)==0)?140:0;
// Change 140 above to match whatever you have in CSS
//experiment with 'fast','medium','slow', or millisecond values for the speed
$('#container a').animate({top: move_to+'px'}, 1000);
return false;
}
</script>
</head>
<body>
<p id="container">
<a href="some-meaningful-url-if-JS-is-disabled.html"><img src="some-image.jpg" alt="slide-me"></a>
</p>
</body>
</html>