jquery countdown applet implementation code

小云云
Release: 2018-02-05 14:27:24
Original
1566 people have browsed it

jQuery can implement the countdown function. This article mainly introduces the small application of jquery to implement the countdown in detail. It has certain reference value. Interested friends can refer to it. I hope it can help everyone.

html


##

  • 小米 Note 顶配版

    小米 Note 顶配版

    全网通 香槟金 移动联通
    双4G手机 双卡双待

    ¥2998

  • 小米 Note 顶配版

    小米 Note 顶配版

    全网通 香槟金 移动联通
    双4G手机 双卡双待

    ¥2998

Copy after login

jquery


$(function(){ var abj = $("#shop_rec"), timeObj = abj.find('.time'); var starttime = timeObj.data('starttime'); // 定时器函数 function actionDo(){ return setInterval(function(){ timeObj.each(function(index, el) { var t = $(this), surplusTime = t.data('endtime') -starttime; if (surplusTime <= 0) { t.html("活动已经开始"); } else{ var year = surplusTime/(24*60*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+"年") }; if (showMonth>0) { t.append(""+showMonth+"月") }; if (showDay>0) { t.append(""+showDay+"天") }; if (showHour>=0) { t.append(""+showHour+"小时") }; if (showMinute>=0) { t.append(""+showMinute+"分钟") }; if (showSeconds>=0) { t.append(""+showSeconds+"秒") }; }; }); starttime++; },1000); // 设定执行或延时时间 }; // 执行它 actionDo(); });
Copy after login

Summary

It’s not particularly good, but it’s no problem for small applications.

Related recommendations:


jQuery implementation code for countdown and SMS countdown functions

The above is the detailed content of jquery countdown applet implementation code. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!