js定时更换图片
//定时更换图片: 调用: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 }