Oops. Didn't run the code long enough to see that, my mistake. When
this[i] is undefined the jQ object returns with document. Using eq()
instead can fix it.
jQuery.fn.showLoop = function(){
var i = i || 0, self = this;
this.eq(i).show(600, function(){
self.showLoop(++i);
});
};
but the solution Karl posted should also work and is more concise:
var $type = $('.type'), i = 0;
(function(){
$type.eq(i++).show('normal', arguments.callee);
})();
cheers,
- ricardo
On Mar 17, 12:30 am, Tom Shafer <[email protected]> wrote:
> doesnt seem to work get a recursion error
>
> thanks!
> On Mar 16, 7:26 pm, ricardobeat <[email protected]> wrote:
>
> > jQuery.fn.showLoop = function(i){
> > var i = i || 0,
> > self = this;
> > $( this[i] ).show(600, function(){
> > self.showLoop(++i);
> > });
>
> > };
>
> > $('.type').showLoop();
>
> > On Mar 16, 7:27 pm, Tom Shafer <[email protected]> wrote:
>
> > > how can i loop through each div on a page and have them appear one by
> > > one
> > > i am trying
>
> > > var arrayList2 = $.makeArray(document.getElementsByClassName
> > > (".type"));
>
> > >
> > > $.each(arrayList2,function() {
> > > $(this).show();
> > > });
>
> > > thanks
>
> > > -tj