Implementation of jQuery group buying Countdown special effects

Source: Internet
Author: User

Implementation of jQuery group buying Countdown special effects

This article mainly introduces the implementation method of jQuery group buying Countdown special effects, which can achieve a relatively fixed time countdown effect and is very useful. If you need it, you can refer

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

<! 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> countdown test </title>

<Script src = "jquery-1.6.2.min.js" type = "text/javascript"> </script>

<Script>

Function lxfEndtime (){

$ (". Lxftime"). each (function (){

Var lxfday = $ (this). attr ("lxfday"); // variable used to determine whether to display days

Var endtime = new Date ($ (this). attr ("endtime"). getTime ();

// Get the end date (millisecond value)

Var nowtime = new Date (). getTime ();

// Today's date (millisecond value)

Var youtime = endtime-nowtime; // how long is there (millisecond value)

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 );

// "%" Indicates the remainder operation. It can be understood as 60 and then the remainder is obtained.

If (endtime <= nowtime ){

Expires (this).html ("expired ")

// If the end date is earlier than the current date, an expiration prompt is displayed.

} Else {

If ($ (this). attr ("lxfday") = "no "){

Expires (this).html ("<I> remaining time: </I> <span> "+ CHour +" </span> <span> "+ CMinute +" </span> <span> "+ CSecond +" </ span> seconds ");

// Output data without days

} Else {

Expires (this).html ("<I> remaining time: </I> <span> "+ days +" </span> <em> day </em> <span> "+ CHour +" </span> <em> </em> <span> "+ CMinute +" </span> <em> Points </em> <span> "+ CSecond +" </span> <em> seconds </em> ");

// Output data with days

}

}

});

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> countdown to days

<Div class = "lxftime" endtime = "11/15/2015 17:24:0"> </div>

<Div class = "lxftime" endtime = "11/8/2015 :3:20"> </div>

<Div class = "lxftime" endtime = "9/6/2015 6:1:0"> </div>

<Div class = "lxftime" endtime = "6/6/2016 :3:5"> </div>

</Div>

<P> </p>

<Div class = "haveday">

<H1> No countdown to days

<Div class = "lxftime" endtime = "11/15/2015 17:24:0" lxfday = "no"> </div>

<Div class = "lxftime" endtime = "11/8/2015 :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 :3:5" lxfday = "no"> </div>

</Div>

</Body>

</Html>

I hope this article will help you with jQuery programming.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.