<script type="text/javascript"> var timeout; $(function () { timeout = setInterval(showsykssj, 1000); }) function showsykssj() { /*显示剩余考试时间*/ var hour = 12; //结束时间 var minite = 0; var second = 0; var date1 = new Date(1986, 1, 22, hour, minite, second); var date2 = new Date(1986, 1, 22, new Date().getHours(), new Date().getMinutes(), new Date().getSeconds()); var nDiff = date1 - date2; var nHour, nMini, nSecond; nHour = parseInt(nDiff / 3600000); nMini = parseInt(nDiff % 3600000 / 60000); nSecond = parseInt(nDiff % 60000 / 1000); if (nMini == 0 && nSecond == 0) { alert("考试时间到,系统自动交卷。"); clearInterval(timeout); } else { document.getElementById("sykssj").innerHTML = "距离" + hour + "点" + minite + "分" + second + "秒还有:" + nHour + "小时" + nMini + "分" + nSecond + "秒"; } } </script>