js代码
<script type="text/javascript"> var isStop = -1; $(document).ready(function() { var si1 = setInterval(function() { var seconds = new Date().getSeconds(); var sdegree = seconds * 6; var srotate = "rotate(" + sdegree + "deg)"; $("#sec").css({ "-moz-transform": srotate, "-webkit-transform": srotate }) }, 1000); var si2 = setInterval(function() { var hours = new Date().getHours(); var mins = new Date().getMinutes(); var hdegree = hours * 30 + (mins / 2); var hrotate = "rotate(" + hdegree + "deg)"; $("#hour").css({ "-moz-transform": hrotate, "-webkit-transform": hrotate }) }, 1000); var si3 = setInterval(function() { var mins = new Date().getMinutes(); var mdegree = mins * 6; var mrotate = "rotate(" + mdegree + "deg)"; $("#min").css({ "-moz-transform": mrotate, "-webkit-transform": mrotate }) }, 1000); $("#start").click(function() { if (isStop == 1) { si1 = setInterval(function() { var seconds = new Date().getSeconds(); var sdegree = seconds * 6; var srotate = "rotate(" + sdegree + "deg)"; $("#sec").css({ "-moz-transform": srotate, "-webkit-transform": srotate }) }, 1000); si2 = setInterval(function() { var hours = new Date().getHours(); var mins = new Date().getMinutes(); var hdegree = hours * 30 + (mins / 2); var hrotate = "rotate(" + hdegree + "deg)"; $("#hour").css({ "-moz-transform": hrotate, "-webkit-transform": hrotate }) }, 1000); si3 = setInterval(function() { var mins = new Date().getMinutes(); var mdegree = mins * 6; var mrotate = "rotate(" + mdegree + "deg)"; $("#min").css({ "-moz-transform": mrotate, "-webkit-transform": mrotate }) }, 1000); isStop = isStop * (-1) } else { clearInterval(si1); clearInterval(si2); clearInterval(si3); isStop = isStop * (-1) } }) }); </script>