javascript - setInterval() for an analogue clock -
i'm quite new javascript , have trouble working etinterval()
.
i'm creating analogue clock exercise. have function settime()
gets , displays time rotating arrows accordingly.
i want execute function again , again.
here code :
$(document).ready(function(){ function settime(){ var d = new date(); var hour = d.gethours(); var minute = d.getminutes(); var hourrotation = hour * 30 + (minute / 2); var minuterotation = minute * 6; $("#small").css({ "-webkit-transform": "rotate(" + hourrotation + "deg)", "-moz-transform": "rotate(" + hourrotation + "deg)", "-o-transform": "rotate(" + hourrotation + "deg)" }); $("#big").css({ "-webkit-transform": "rotate(" + minuterotation + "deg)", "-moz-transform": "rotate(" + minuterotation + "deg)", "-o-transform": "rotate(" + minuterotation + "deg)" }); }; function clockstart(){ setinterval(settime(),1000); settime(); } clockstart(); });
i'd understand method , how use it. examples find looked obvious, still can't make work.
you making function call in setinterval()
.
what want :
setinterval(settime,1000);
Comments
Post a Comment