Este artículo describe el código de implementación de cuenta regresiva simple de JS. Compártelo para su referencia, como sigue:
<Div> Todavía hay días antes del final del evento <span id = "day"> </span> horas <span id = "min"> </span> minutos <span id = "sec"> </span> segundos </div> <script type = "text/javaScript"> var day = document.getElementByid ("day"); var horas = document.getElementByid ("horas"); var min = var Min = document.getElementById ("min"); var sec = document.getElementById ("sec"); var DiferenceHour = -1; var diferenceMinute = -1; var diferencesEcond = -1; // var tday = new fecha ("07 20,2016 10:00:00") // ** Tiempo de contadores de forma de tiempo note Var TDAY = nueva fecha ("07/2016 10:00:00") // es decir: mes/día/año var daysms = 24 * 60 * 60 * 1000; var soursms = 60 * 60 * 1000; var secundarios = 60 * 1000; var microsegundo = 1000; function clock () {var tiempo = new date (); var hora = time.gethours (); var minuto = time.getminutes (); var Second = Time.getSeconds (); var timevalue = "" + ((hora> 12)? Hora-12: hora); TimeValue + = ((minuto <10)? ": 0": ":") + minuto; TimeValue + = ((segundo <10)? ": 0": ":") + segundo; TimEvalue += ((hora> 12)? "PM": "AM"); // document.formnow.now.value = TimeValue var converthour = DiferingHour; var convertminte = diferenceMinute; var convertSecond = DiferencesEcond; var diffms = tday.gettime () - time.gettime (); DifferenceHour = Math.Floor (Diffms / Daysms); Diffms -= Diference Hour * Daysms; DiferenceMinute = Math.floor (diffms / horasms); Diffms -= DiferenceMinute * Hoursms; DiferencesEcond = Math.floor (diffms / SECCES); Diffms -= DiferencesEcond * SECINMS; var dsecs = Math.floor (diffms / microsegundo); if (converthour! = Diferinghour) {day.innerhtml = DiferingHour; } if (ConvertMinute! = DiferenceMinute) {Hours.innerhtml = DiferenceMinute; } if (convertSeCond! = DiferencesEcond) {min.innerhtml = DiferencesEcond; } sec.innerhtml = dsecs; // document.formnow.tnow.value = DifferenceHour DiferenceMinute + DiferencesEcond + DSECS SettimeOut ("Clock ()", 1000);} Clock (); </script>For more information about JavaScript, please check this site's special topics: "Summary of JavaScript Time and Date Operation Skills", "Summary of JavaScript Switching Effects and Skills", "Summary of JavaScript Search Algorithm Skills", "Summary of JavaScript Animation Special Effects and Skills", "Summary of JavaScript Errors and Debugging Skills", "Summary of JavaScript Data Structures and Algorithm Skills", "Resumen del algoritmo y habilidades de traversal de JavaScript" y "Resumen del uso de la operación matemática de JavaScript"
Espero que este artículo sea útil para la programación de JavaScript de todos.