停止动画jQ [英] stop the animation jQ

查看:73
本文介绍了停止动画jQ的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个问题,我不知道如何通过鼠标悬停来停止我的功能,而通过鼠标悬停来重新启动它

ive got the problem that i dont know how to stop my function with mouseover and restart it with mouseout

首先,这是我的测试代码:

first here is my test-code:

  <script type="text/javascript">

  function fadeEngine(x) {

  var total_divs=3; //setze hier die nummer der gewollten divs

                  var y=x;

                  if(x==total_divs) y=1; else y++;

                  $("#fade"+x).css("display","none");

                  $("#fade"+y).fadeIn("slow");

                  setTimeout('fadeEngine('+y+')',3000); //modifi alle 3000 miliseconds nen neuen div
          }

        fadeEngine(0); //Initialisation des Scripts

  </script>

<script type="text/javascript">
$(document).ready(function(){
/*
    $("#container").hover(function(){
            stop('mouse over');
    },function(){
            alert('mouse out');
    });
*/
/*
$("#container").hover(function()
   {
      $(this).stop().fadeTo("slow", 1.00);
   },
   function()
   {
      $(this).stop().fadeTo("fast", 0.50);
   });
*/



});

</script>
</head>
<body>

<div id="container" style="width:200px;height:200px;background:#afafaf;color:#red;">

    <div id="fade1">Content  one</div>
    <div id="fade2" style="display:none">Content  two</div>
    <div id="fade3" style="display:none">Content three</div>
</div>
    <div class="blocker">&nbsp;</div>
</body>
</html>

如果我将鼠标移到contentdiv上,如果我将其移出div,我将如何停止我的功能fadeEngine?

How i can do this to stop my function fadeEngine if im go over the contentdiv and start it if im move out of the div?

非常感谢您的帮助

推荐答案

为所有#fade X元素提供一个类(例如.faders),然后使用:

Give all of your #fadeX elements a class (say .faders) and then use:

$('.faders').stop();

或者给容器div一个ID,例如#faderbox并说:

Or give the container div an id like #faderbox and say:

$('#faderbox div').stop();

这篇关于停止动画jQ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆