This article mainly introduces jquery's small countdown application in detail, which has some reference value. Interested friends can refer to it and hope to help you. This article mainly introduces jquery's small countdown application in detail, which has some reference value. Interested friends can refer to it and hope to help you.
Html
Jquery
$ (Function () {var abj = $ ("# shop_rec"), timeObj = abj. find ('. time'); var starttime = timeObj. data ('starttime'); // The timer function actionDo () {return setInterval (function () {timeObj. each (function (index, el) {var t = $ (this), surplusTime = t. data ('endtime')-starttime; if (surplusTime <= 0) {t.html ("activity started ");} else {var year = surplusTime/(24x60*60*365), showYear = parseInt (year), month = (year-showYear) * 12, showMonth = parseInt (month), day = (month-showMonth) * 30, showDay = parseInt (day), hour = (day-showDay) * 24, showHour = parseInt (hour), minute = (hour-showHour) * 60, showMinute = parseInt (minute), seconds = (minute-showMinute) * 60, showSeconds = parseInt (seconds); t.html (""); if (showYear> 0) {t. append ("" + showYear + "year")}; if (showMonth> 0) {t. append ("" + showMonth + "month")}; if (showDay> 0) {t. append ("" + showDay + "day")}; if (showHour> = 0) {t. append ("" + showHour + "Hour")}; if (showMinute> = 0) {t. append ("" + showMinute + "min")}; if (showSeconds> = 0) {t. append ("" + showSeconds + "seconds") };}); starttime ++ ;}, 1000); // set the execution or delay time }; // execute it actionDo ();});
Summary
Not especially good, but there is no problem with small applications.