On Apr 22, 9:55 pm, mkmanning <michaell...@gmail.com> wrote:
> With arguments.callee wouldn't you still lose the original 'this' ?
>
> Why not a closure, just set 'this' to 'that'. Also, you should return
> the jQuery object:

Yes, this works!  Bravo!
Proper use of the setInterval( ) function with this-and-that closure!

This is what I entered:

(function($) {
        $.fn.JSClock = function() {
                var that = this;
                setInterval(function() {
                        function timeFormat(i) {
                                if (i < 10) {
                                        i="0" + i;
                                }
                        return i;
                        }
                        var today=new Date();
                        var h=today.getHours();
                        var m=today.getMinutes();
                        var s=today.getSeconds();
                        var m=timeFormat(m);
                        var s=timeFormat(s);
                        that.html("Local Time: " + h +":"+ m +":"+s);
                }, 500);
                return this;
        }
})(jQuery);

Many thanks!

Roddy

Reply via email to