Home Web Front-end JS Tutorial jQuery group purchase countdown special effect implementation method_jquery

jQuery group purchase countdown special effect implementation method_jquery

May 16, 2016 pm 04:00 PM
jquery Countdown Group buy

The example in this article describes how to implement jQuery group purchase countdown special effects. Share it with everyone for your reference. The specific implementation method is as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>倒计时测试</title>
<script src="jquery-1.6.2.min.js" type="text/javascript"></script>
<script>
 function lxfEndtime(){
 $(".lxftime").each(function(){
  var lxfday=$(this).attr("lxfday");//用来判断是否显示天数的变量
  var endtime = new Date($(this).attr("endtime")).getTime();
  //取结束日期(毫秒值)
  var nowtime = new Date().getTime();
  //今天的日期(毫秒值)
  var youtime = endtime-nowtime;//还有多久(毫秒值)
  var seconds = youtime/1000;
  var minutes = Math.floor(seconds/60);
  var hours = Math.floor(minutes/60);
  var days = Math.floor(hours/24);
  var CDay= days ;
  var CHour= hours % 24;
  var CMinute= minutes % 60;
  var CSecond= Math.floor(seconds%60);
  //"%"是取余运算,可以理解为60进一后取余数,然后只要余数。
  if(endtime<=nowtime){
    $(this).html("已过期")
    //如果结束日期小于当前日期就提示过期啦
    }else{
    if($(this).attr("lxfday")=="no"){
    $(this).html("<i>剩余时间:</i><span>"+CHour+"</span>时<span>"+CMinute+"</span>分<span>"+CSecond+"</span>秒");
    //输出没有天数的数据
    }else{
    $(this).html("<i>剩余时间:</i><span>"+days+"</span><em>天</em><span>"+CHour+"</span><em>时</em><span>"+CMinute+"</span><em>分</em><span>"+CSecond+"</span><em>秒</em>");
    //输出有天数的数据
    }
   }
 });
 setTimeout("lxfEndtime()",1000);
 };
$(function(){
 lxfEndtime();
});
</script>
<style type="text/css">
<!--
*{
  font-style: normal;
  font-weight: normal;}
.haveday {
  padding: 20px;
  border: 1px dashed #000;
  margin-right: auto;
  margin-left: auto;
  width: 300px;
}
-->
</style>
</head>
<body>
<div class="haveday">
<h1>含有天数的倒计时</h1>
<div class="lxftime" endtime="11/15/2015 17:24:0"></div>
<div class="lxftime" endtime="11/8/2015 3:3:20"></div>
<div class="lxftime" endtime="9/6/2015 6:1:0"></div>
<div class="lxftime" endtime="6/6/2016 9:3:5"></div>
</div>
<p></p>
<div class="haveday">
<h1>没有天数的倒计时</h1>
<div class="lxftime" endtime="11/15/2015 17:24:0" lxfday="no"></div>
<div class="lxftime" endtime="11/8/2015 3:3:20" lxfday="no"></div>
<div class="lxftime" endtime="9/6/2015 6:1:0" lxfday="no"></div>
<div class="lxftime" endtime="6/6/2016 9:3:5" lxfday="no"></div>
</div>
</body>
</html>
Copy after login

I hope this article will be helpful to everyone’s jQuery programming.

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1266
29
C# Tutorial
1239
24
Detailed explanation of jQuery reference methods: Quick start guide Detailed explanation of jQuery reference methods: Quick start guide Feb 27, 2024 pm 06:45 PM

Detailed explanation of jQuery reference method: Quick start guide jQuery is a popular JavaScript library that is widely used in website development. It simplifies JavaScript programming and provides developers with rich functions and features. This article will introduce jQuery's reference method in detail and provide specific code examples to help readers get started quickly. Introducing jQuery First, we need to introduce the jQuery library into the HTML file. It can be introduced through a CDN link or downloaded

How to use PUT request method in jQuery? How to use PUT request method in jQuery? Feb 28, 2024 pm 03:12 PM

How to use PUT request method in jQuery? In jQuery, the method of sending a PUT request is similar to sending other types of requests, but you need to pay attention to some details and parameter settings. PUT requests are typically used to update resources, such as updating data in a database or updating files on the server. The following is a specific code example using the PUT request method in jQuery. First, make sure you include the jQuery library file, then you can send a PUT request via: $.ajax({u

How to get group buying link on Douyin Group Buying How to get group buying link on Douyin Group Buying Apr 24, 2024 am 11:11 AM

1. Register a Douyin merchant account: As a merchant, you need to first register a merchant account on the Douyin platform and complete relevant information filling and certification. 2. Create a group buying activity: In the merchant backend, find the relevant settings for the group buying activity, fill in the product information, group buying price, discount intensity, etc., and set the activity rules. 3. Obtain the group buying link: After the group buying activity is successfully created, the system will generate a group buying link and QR code. Merchants can share the link or QR code with users, allowing users to participate in group buying by clicking or scanning. 4. Publicity and promotion: Merchants can use advertisements, live broadcasts, and short videos on the Douyin platform

jQuery Tips: Quickly modify the text of all a tags on the page jQuery Tips: Quickly modify the text of all a tags on the page Feb 28, 2024 pm 09:06 PM

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: &lt

Use jQuery to modify the text content of all a tags Use jQuery to modify the text content of all a tags Feb 28, 2024 pm 05:42 PM

Title: Use jQuery to modify the text content of all a tags. jQuery is a popular JavaScript library that is widely used to handle DOM operations. In web development, we often encounter the need to modify the text content of the link tag (a tag) on ​​the page. This article will explain how to use jQuery to achieve this goal, and provide specific code examples. First, we need to introduce the jQuery library into the page. Add the following code in the HTML file:

How to cancel the 10-second countdown on booting up Win10? Three ways to cancel the countdown on booting up Win10 How to cancel the 10-second countdown on booting up Win10? Three ways to cancel the countdown on booting up Win10 Feb 29, 2024 pm 07:25 PM

In win10, the boot countdown is enabled by default. When we turn on the computer, we will see a countdown interface, usually a 10-second countdown. Within this time, we can choose whether to continue booting or perform some other operations. Although the boot countdown brings some convenience to our system, it may also cause trouble in some cases. I want to cancel the display, but I don’t know how to do it. This article brings you how to cancel the countdown of several seconds after booting up Win10. Understand the win10 boot countdown. In win10, the boot countdown is enabled by default. When we turn on the computer, we will see a countdown interface, usually a 10-second countdown. Within this time, we can choose whether to continue booting or proceed

How to remove the height attribute of an element with jQuery? How to remove the height attribute of an element with jQuery? Feb 28, 2024 am 08:39 AM

How to remove the height attribute of an element with jQuery? In front-end development, we often encounter the need to manipulate the height attributes of elements. Sometimes, we may need to dynamically change the height of an element, and sometimes we need to remove the height attribute of an element. This article will introduce how to use jQuery to remove the height attribute of an element and provide specific code examples. Before using jQuery to operate the height attribute, we first need to understand the height attribute in CSS. The height attribute is used to set the height of an element

Douyin group buying merchant application Douyin group buying merchant application Apr 16, 2024 am 10:08 AM

1. Register and log in to Douyin account and complete real-name authentication. 2. Go to the Douyin group buying page and provide the merchant name, business license and other relevant information. 3. Then upload the product name, price, pictures and detailed description. After completing the above steps, submit the information for Douyin review. 4. After passing the review, the merchant can launch the Douyin group buying page, publish preferential activities and provide group buying services.

See all articles