日期:2014-05-16 浏览次数:20414 次
<div class="div1">1</div>
$(document).ready(function() {
picTimer = setInterval(function()
{showPic();},1000);
function showPic() {
$(".div1").animate({marginTop:"40px"},500);
$(".div1").animate({marginTop:"-40px"},500);
}
$(".div1").hover(
function() {
clearInterval(picTimer);
}
,function(){
}
);
});
<!DOCTYPE HTML>
<html>
<head>
<meta charset="gbk" />
<title></title>
<style>
div {
position:absolute; left:200px; top:200px;
border:1px solid red;
width:20px; height:20px;
}
</style>
</head>
<body>
<div class="div1">1</div>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function() {
picTimer = setInterval(showPic, 1000);
function showPic() {
$(".div1").animate({marginTop:"40px"},500);
$(".div1").animate({marginTop:"-40px"},500);
}
$(".div1").mouseover(function(){
$(this).stop();
clearInterval(picTimer);
}).mouseout(function(){
picTimer = setInterval(showPic, 1000);
})
});
</script>
</body>
</html>