setInterval should be the solution. How does your implementation with
it look like?

On Apr 22, 1:23 pm, kiusau <kiu...@mac.com> wrote:
> QUESTION:  How do I get a function to repeat itself an unspecified
> number of times?
>
> BACKGROUND:  I have created a digital clock with which I very
> satisfied except for one shortcoming:  it displays only once and stops
> ticking.  The only way to keep track of the time is to refresh the
> page.  I have introduced the setInterval( ) function in a variety of
> ways to compel JSClock() to repeat itself, but to no avail.
>
> SOURCE CODE:
>
> (function($) {
>                   $.fn.JSClock = function() {
>                                 var today=new Date();
>                                 var h=today.getHours();
>                                 var m=today.getMinutes();
>                                 var s=today.getSeconds();
>                                 m=timeFormat(m);
>                                 s=timeFormat(s);
>                                 function timeFormat(i) {
>                                         if (i < 10) {
>                                                 i="0" + i;
>                                         }
>                                 return i;
>                                 }
>                                 this.html("Local Time: " + h +":"+ m +":"+s);
>                         }
>
> })(jQuery);
>
> $(document).ready(function() {
>         $('#clock').JSClock();
>
> });

Reply via email to