Your script doesn't tell the element to float back once it has reached the right side of the page. Here's a possible solution:
Code:
<!doctype html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<title>Move it</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
.to-move {
width: 400px;
height:70px;
left: -400px;
top:100px;
position:absolute;
opacity: 0.6;
}
.link-spanner{
position:absolute;
width:100%;
height:100%;
top:0;
left: 0;
z-index: 1;
}
</style>
<script>
function move_it()
{
if($('.to-move').css({left: '-400px'}))
{$('.to-move').animate({left: '100%', top: '500px'}, 10000)}
if($('.to-move').css({left: '100%'}))
{$('.to-move').animate({left: '-400px', top: '100px'}, 10000)}
}
$(document).ready(function(){
move_it()
setInterval("move_it()",500)
});
</script>
</head>
<body>
<div class="to-move">
<h3>Some text, click on text to go to Sales page</h3>
<a href="store.php"><span class="link-spanner"></span></a>
</div>
</body>
</html>
Bookmarks