标题:jquery中如何关闭settimeout循环
只看楼主
pigzee
Rank: 2
等 级:论坛游民
帖 子:20
专家分:69
注 册:2010-3-30
结帖率:100%
 问题点数:0 回复次数:1 
jquery中如何关闭settimeout循环
如题
js中
$timer=setTimeout("Times()",1000); //在1秒后运行Times();
function Times(){alert('Hello world')}; //Times() 的内容;
 clearTimeout($timer); //移除设置

jquery中使用了$,如何结束循环呢?我的函数是含有参数的。呵呵。

我一个22分,哈哈,给的分不多,见谅!
搜索更多相关主题的帖子: jquery settimeout 
2010-10-14 21:28
pigzee
Rank: 2
等 级:论坛游民
帖 子:20
专家分:69
注 册:2010-3-30
得分:0 
嘿嘿,我想到一个方法,设置一个状态位,呵呵。
类似,呵呵
function Shift(Obj){
                    var me = this;
                    if (typeof (Obj)=="string") this.Obj = document.getElementById(Obj);
                    else this.Obj = Obj;
                    this.Timer = 10;
                    this.Move = function (y1,y2)
                    {
                        
                        if(y1 == y2){
                            alert('---');
                            $("#cloneList").empty();
                        }else{
                            var y1 = parseInt(this.Obj.style.top,10);
                            var yc = Math.ceil(Math.abs(y1-y2)/20);
                            this.Obj.style.top = y1 + yc * (y1<y2?1:-1) + "px";
                            setTimeout(function (){me.Move(y1,y2)},me.Timer);
                        }                  
                    }
                }
2010-10-14 21:35



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-322925-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.814878 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved