首页 > Web开发 > 详细

js定时更换图片

时间:2017-10-11 15:14:29      阅读:205      评论:0      收藏:0      [点我收藏+]
//定时更换图片:  调用: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
        }

 

js定时更换图片

原文:http://www.cnblogs.com/zhangwj/p/7650412.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!