Saturday, February 28, 2009

[jQuery] Re: Tell if its the last item on a .each?

an example

var arr = new Array("a", "b", "c", "d");
$.each(arr, function(idx) {
if (idx == (arr.length - 1)) {
// at last item
}
});

On Feb 28, 12:49 pm, Toaster <mr.toas...@gmail.com> wrote:
> Hey
>
> How do I tell if the item on a .each is the last one? For example,
> lets say I want to add a comma after every item and not the last one,
> how would I do that?
>
> Thanks in advance.

No comments: