1. 程式人生 > >js定時更換圖片

js定時更換圖片

ole att 更換 ttr set con color top mile

//定時更換圖片:  調用: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定時更換圖片