Examples of Countdown effect implemented by jQuery, jquery Summary
This example summarizes the countdown effect implemented by jQuery. We will share this with you for your reference. The details are as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
When we read the time field in the database in webservice, we can divide the time to judge. The Javascript code is as follows:
<Script type = "text/javascript" src = "jquery. js "> </script> <script type =" text/javascript "> function Times () {var tempTime = document. getElementById ("currTime "). innerHTML. split (":"); var hour = tempTime [0]; var minute = tempTime [1]; var second = tempTime [2]; if (second> = 1) {second = (second-1> 9 )? (Second-1): "0" + (second-1);} else {second = "59"; if (minute> = 1) {minute = (minute-1> 9 )? (Minute-1): "0" + (minute-1);} else {minute = "59"; if (hour> = 1) {hour = (hour-1> 9 )? (Hour-1): "0" + (hour-1);} else {minute = "00"; hour = "0" + 0 ;}} document. getElementById ("currTime "). innerHTML = hour + ":" + minute + ":" + second; if (hour = 0 & minute = 0 & second = 0) {document. getElementById ("currTime "). style. display = "none";} elsesetTimeout (Times, 1000);} // call when the form is loaded. Equivalent to the onload () event (function gettime () {$. ajax ({contentType: "application/json", type: "POST", url: "WebService. asmx/Gettime ", data:" {'id': '1'} ", dataType: 'json', success: function (msq) {document. getElementById ("currTime "). innerHTML = msq. d ;}}); setTimeout (Times, 1000) ;}) (); </script>
Multiple countdown >>>
Code:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">