I'm doing a clock in javascript and I am not sure this way is the best way to rotate the pointers.
Is this ok, or is there a better way?
// browser vendors var browsers = [ 'webkit', 'Moz', 'ms', 'O', '']; // function to move the pointers function moveMe(el, unit) { var deg = unit * 360 / 60; browsers.each(function (b) { el.style[b + 'Transform'] = 'rotate(' + deg + 'deg)'; }); } // function to check the time function checkTime() { var date = new Date(); var seconds = date.getSeconds(); var minutes = date.getMinutes(); var hours = date.getHours(); moveMe(sPointer, seconds); !seconds && moveMe(mPointer, minutes); !minutes && moveMe(hPointer, hours); }
The fiddle I'm playing with is here.