0

I've a simple each loop and I want count loops of this while,and find The final number then save counter variable and use in my codes, how can do posible...??!

var counter = 0;

$.each(data, function( key, value) {
  counter++;
     if(counter == /*The final number*/)
     {
        //Do Some Codes
     }


})
MojtabaSh
  • 627
  • 1
  • 11
  • 26

1 Answers1

0

You can count loop like this

.each(function (i) { }

here i will give you counter value

Sid
  • 801
  • 8
  • 19
  • please describe your codes, i don't understand very well – MojtabaSh Apr 21 '14 at 15:50
  • You want to count your loop here i will give you counter value and in side that you can set whatever logic you want, have you tried this? – Sid Apr 22 '14 at 04:41
  • and if you want to do any thing in your last loop then compare value of i with your data.length. – Sid Apr 22 '14 at 04:43