js定时更换图片

来源:互联网 发布:mac全屏后切换桌面 编辑:程序博客网 时间:2024/06/05 21:14
//定时更换图片:  调用:smileChange.start();  smileChange.stop();var smileChange = {            start: function () {                var that = this;//鍐呭眰鐨勫唴灞傚嚱鏁扮殑this浼氬嚭闂                this.intervalId = setInterval(function () {                    clearTimeout(that.timeoutId);                    $(".third .smile img").attr("src", "img/smile-on-2.png");                    that.timeoutId = setTimeout(function () {                        $(".third .smile img").attr("src", "img/smile-off-2.png");                    }, 500);                    //console.log("start  timeout ID "+that.timeoutId);                }, 1000);            },            stop: function () {                console.log("stop timeout id" + this.timeoutId);                clearInterval(this.intervalId);                clearTimeout(this.timeoutId);                console.log("stop interval id" + this.intervalId);            },            changing: 0,            intervalId: 0,            timeoutId: 0        }

0 0
原创粉丝点击