Unable to get value of variable outside the each loop in jQuery

When we define the variable in each loop its default the local scope variable. We need to define the variable outside the each loop(before loop) and assign the new value to variable in loop.

Remember one thing we need to assign value for global variable inside the loop, you not need to add var before varaible ssign statement. if we add var it will treated as in local scope and not be assignable out side the loop. 

Leave a Reply

Your email address will not be published. Required fields are marked *

10 + 2 =

Scroll to top