body,html{overflow-x:hidden;} *{margin:0; padding: 0;} .circle{width:100px; height:100px; line-height: 100px; text-align: center; background: #000; color: #fff; font-size: 14px; border-radius:50%; position: absolute; right: 10px; bottom: 10px; cursor: pointer;}
<div class="circle">在线问答</div>
<script src="jquery-1.12.0.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function(){ var timer=null; timer=setTimeout(function(){ $(".circle").animate({right:"-50px"},1000); },5000); $(".circle").hover(function(){ $(this).animate({right:"10px"},1000); if (timer) { window.clearTimeout(timer); } },function(){ $(this).animate({right:"-50px"},2000); }) }) </script>
重要的是setTimeout,animate及何时清除定时器。